Package org.bardframework.commons.utils
Class DateTimeUtils
java.lang.Object
org.bardframework.commons.utils.DateTimeUtils
Created by Vahid Zafari on 8/12/2016.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic LocalDateTimedateTimeFromEpochMills(long dateTimeAsMills) Obtains an instance ofLocalDateTimeusing milliseconds from the epoch of 1970-01-01T00:00:00Z.static LocalDatefromEpochMills(long dateAsMills) static LocalDateTimefromEpochMills(long dateTimeAsMills, ZoneId zone) Obtains an instance ofLocalDateTimeusing milliseconds from the epoch of 1970-01-01T00:00:00Z.static longstatic ChronoUnittoChronoUnit(TimeUnit unit) static longtoEpochMills(LocalDate date) calculate milliseconds past from the epoch of 1970-01-01T00:00:00Z.static longtoEpochMills(LocalDateTime dateTime) calculatee milliseconds past from the epoch of 1970-01-01T00:00:00Z.static longtoEpochMills(OffsetDateTime dateTime) static StringtoLocalString(LocalDate date) convert date to string divided by '/'static StringtoLocalString(LocalDateTime dateTime) convert date to string divided by '/'static TimeUnittoTimeUnit(ChronoUnit unit)
-
Field Details
-
YEAR_DURATION_MILLS
public static final long YEAR_DURATION_MILLS- See Also:
-
-
Method Details
-
toEpochMills
calculate milliseconds past from the epoch of 1970-01-01T00:00:00Z.- Parameters:
date- an instance of (@code LocalDate)- Returns:
- past milliseconds from 1970-01-01T00:00:00Z according (!@code date) at 23:59:59:99:999.
- Throws:
IllegalArgumentException- if null date passed to method.
-
fromEpochMills
-
dateTimeFromEpochMills
Obtains an instance ofLocalDateTimeusing milliseconds from the epoch of 1970-01-01T00:00:00Z. The seconds and nanoseconds are extracted from the specified milliseconds.- Parameters:
dateTimeAsMills- the number of milliseconds after 1970-01-01T00:00:00Z- Returns:
- a LocalDateTime, not null
- Throws:
DateTimeException- if the instant exceeds the maximum or minimum instant
-
fromEpochMills
Obtains an instance ofLocalDateTimeusing milliseconds from the epoch of 1970-01-01T00:00:00Z. The seconds and nanoseconds are extracted from the specified milliseconds.- Parameters:
dateTimeAsMills- the number of milliseconds from 1970-01-01T00:00:00Z.zone- an isntance of (@code ZoneId) specify zone id for calculating LocalDateTime- Returns:
- a LocalDateTime, not null
- Throws:
DateTimeException- if the instant exceeds the maximum or minimum instantIllegalArgumentException- if null zone passed to method.
-
toEpochMills
calculatee milliseconds past from the epoch of 1970-01-01T00:00:00Z.- Parameters:
dateTime- an instance of (@code LocalDateTime)- Returns:
- past milliseconds from 1970-01-01T00:00:00Z.
- Throws:
IllegalArgumentException- if null dateTime passed to method.
-
toEpochMills
-
toLocalString
convert date to string divided by '/'- Parameters:
dateTime- the dateTime- Returns:
- null if date is null, else date with 'yyyy/MM/dd HH:mm' format
-
toLocalString
convert date to string divided by '/'- Parameters:
date- the dateTime- Returns:
- null if date is null, else date with 'yyyy/MM/dd' format
-
toTimeUnit
-
toChronoUnit
-
getNowUtcMills
public static long getNowUtcMills()
-