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
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longdiffDays(long startDateEpochMills, long endDateEpochMills) static LocalDateTimefromEpochMills(long dateAsMills) static LocalDateTimefromEpochMills(long dateTimeAsMills, ZoneId zone) Obtains an instance ofLocalDateTimeusing milliseconds from the epoch of 1970-01-01T00:00:00Z.static longstatic longstatic longleftDays(long startDateEpochMills) static longremainDays(long endDateEpochMills) static longtoEpochMills(LocalDate date) calculate milliseconds past from the epoch of 1970-01-01T00:00:00Z.static longtoEpochMills(LocalDateTime dateTime) static longtoEpochMills(LocalDateTime dateTime, ZoneOffset offset)
-
Field Details
-
ONE_SECOND_MILLS
public static final long ONE_SECOND_MILLS- See Also:
-
ONE_MINUTE_MILLS
public static final long ONE_MINUTE_MILLS- See Also:
-
ONE_HOUR_MILLS
public static final long ONE_HOUR_MILLS- See Also:
-
ONE_DAY_MILLS
public static final long ONE_DAY_MILLS- See Also:
-
ONE_WEEK_MILLS
public static final long ONE_WEEK_MILLS- See Also:
-
ONE_MONTH_MILLS
public static final long ONE_MONTH_MILLS- See Also:
-
ONE_YEAR_MILLS
public static final long ONE_YEAR_MILLS- See Also:
-
-
Constructor Details
-
DateTimeUtils
public DateTimeUtils()
-
-
Method Details
-
getNowUtc
public static long getNowUtc() -
getTodayUtc
public static long getTodayUtc() -
toEpochMills
-
toEpochMills
-
fromEpochMills
-
fromEpochMills
Obtains an instance ofLocalDateTimeusing milliseconds from the epoch of 1970-01-01T00:00:00Z.- Parameters:
dateTimeAsMills- the number of milliseconds after 1970-01-01T00:00:00Zzone- the zone- Returns:
- a LocalDateTime, not null
-
diffDays
public static long diffDays(long startDateEpochMills, long endDateEpochMills) -
leftDays
public static long leftDays(long startDateEpochMills) -
remainDays
public static long remainDays(long endDateEpochMills) -
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.
-