Package host.anzo.commons.utils
Class DateTimeUtils
java.lang.Object
host.anzo.commons.utils.DateTimeUtils
- Since:
- 9/20/2018
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longgetCurrentDayHourTime(long timeInMillis, int hour) static longgetCurrentDayPassedTime(long timeInMillis, @NotNull TimeUnit timeUnit) static longgetCurrentMonthStartTime(long timeInMillis) static @NotNull StringgetFormattedDateTime(@NotNull LocalDateTime localDateTime) static StringgetInternationalTime(long millis) static LocalDategetLocalDate(long epochTime) static LocalDateTimestatic LocalDateTimegetLocalDateTime(long epochTime) static longgetNextDayHourTime(long timeInMillis, int hour, int minute) static LocalDateTimegetNextDayHourTime(LocalDateTime dateTime, int hour, int minute) static longgetNextDayStartTime(long timeInMillis) static longgetNextDayStartTime(long timeInMillis, DayOfWeek dayOfWeek) static longgetNextHourTime(long timeInMillis) static longgetNextHourTime(long timeInMillis, int hour) static longgetNextHourTime(long timeInMillis, int hour, int minute) static LocalDateTimegetNextHourTime(@NotNull LocalDateTime dateTime, int hour, int minute) static longgetNextMonthStartTime(long timeInMillis) static longgetTimeTo(@NotNull LocalDateTime dateTime, @NotNull TimeUnit timeUnit) static longgetTimeToNextDayStart(long timeInMillis) static longgetTimeToNextDayStart(long timeInMillis, DayOfWeek dayOfWeek) static longgetTimeToNextHour(int hour, int minute, TimeUnit timeUnit) static ZonedDateTimegetZonedDateTime(long epochTime) static booleanisSameDay(long date1, long date2) static DayOfWeekparseDay(int day) static intparseTimeSpan(@NotNull String timeSpan, TimeUnit unit) static longtoEpochMillis(@NotNull LocalDateTime localDateTime) static StringtoTimeSpan(long seconds)
-
Field Details
-
MAX_SQL_DATE
-
-
Constructor Details
-
DateTimeUtils
public DateTimeUtils()
-
-
Method Details
-
toEpochMillis
-
getInternationalTime
-
getFormattedDateTime
@NotNull public static @NotNull String getFormattedDateTime(@NotNull @NotNull LocalDateTime localDateTime) -
isSameDay
public static boolean isSameDay(long date1, long date2) - Parameters:
date1- date in epoch formatdate2- date in epoch format- Returns:
trueif date1 is same day as date2,falseotherwise
-
parseTimeSpan
-
toTimeSpan
-
parseDay
- Parameters:
day- day of week when SUNDAY=0 and MONDAY=6- Returns:
- DayOfWeek enum value
-
getLocalDateTime
-
getLocalDateTime
-
getZonedDateTime
-
getLocalDate
-
getCurrentDayPassedTime
- Parameters:
timeInMillis- epoch time stamptimeUnit- time unit- Returns:
- time passed from current day start in specified time unit
-
getCurrentDayHourTime
public static long getCurrentDayHourTime(long timeInMillis, int hour) - Parameters:
timeInMillis- epoch time stamphour- specified hour- Returns:
- time at specified hour at current day
-
getCurrentMonthStartTime
public static long getCurrentMonthStartTime(long timeInMillis) - Parameters:
timeInMillis- epoch time stamp- Returns:
- current month start epoch time
-
getNextHourTime
public static long getNextHourTime(long timeInMillis, int hour, int minute) - Parameters:
timeInMillis- epoch time stamphour- specified hourminute- specified minute- Returns:
- time at specified next hour with minute
-
getNextHourTime
public static LocalDateTime getNextHourTime(@NotNull @NotNull LocalDateTime dateTime, int hour, int minute) -
getNextHourTime
public static long getNextHourTime(long timeInMillis, int hour) - Parameters:
timeInMillis- epoch time stamphour- specified hour- Returns:
- time at specified next hour
-
getNextHourTime
public static long getNextHourTime(long timeInMillis) -
getNextDayStartTime
- Parameters:
timeInMillis- epoch time stampdayOfWeek- day of week- Returns:
- next specified DayOfWeek start epoch time
-
getNextDayStartTime
public static long getNextDayStartTime(long timeInMillis) - Parameters:
timeInMillis- epoch time stamp- Returns:
- next day start epoch time
-
getNextDayHourTime
public static long getNextDayHourTime(long timeInMillis, int hour, int minute) - Parameters:
timeInMillis- epoch time stamphour- specified hourminute- specified minute- Returns:
- time at specified hour the next day
-
getNextDayHourTime
-
getNextMonthStartTime
public static long getNextMonthStartTime(long timeInMillis) - Parameters:
timeInMillis- epoch time stamp- Returns:
- next month start epoch time
-
getTimeToNextDayStart
- Parameters:
timeInMillis- epoch time stampdayOfWeek- day of the week- Returns:
- time in millis to next specified DayOfWeek start
-
getTimeToNextDayStart
public static long getTimeToNextDayStart(long timeInMillis) - Parameters:
timeInMillis- epoch time stamp- Returns:
- time to next day start
-
getTimeTo
public static long getTimeTo(@NotNull @NotNull LocalDateTime dateTime, @NotNull @NotNull TimeUnit timeUnit) - Parameters:
dateTime- date time to calculate time totimeUnit- time unit- Returns:
- time to specified date time in specified time unit
-
getTimeToNextHour
-