Class TimeUtil

java.lang.Object
org.summerboot.jexpress.util.TimeUtil

public class TimeUtil extends Object
Author:
Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
  • Field Details

    • ISO_ZONED_DATE_TIME3

      public static DateTimeFormatter ISO_ZONED_DATE_TIME3
    • UTC_DATE_TIME_FORMATTER

      public static DateTimeFormatter UTC_DATE_TIME_FORMATTER
    • ZONE_ID_ONTARIO

      public static ZoneId ZONE_ID_ONTARIO
    • RANDOM

      protected static Random RANDOM
  • Constructor Details

    • TimeUtil

      public TimeUtil()
  • Method Details

    • getSecondsSinceMidnight

      public static long getSecondsSinceMidnight(Calendar c)
    • getSecondsTillMidnight

      public static long getSecondsTillMidnight(Calendar c)
    • seconds2DHMS

      public static int[] seconds2DHMS(long totalSeconds)
    • seconds2DHMSString

      public static String seconds2DHMSString(long totalSeconds)
    • utcDateTimeToLocalDateTime

      public static String utcDateTimeToLocalDateTime(String utcTime, ZoneId zoneId)
      Maps the UTC time to an ET format.
      Parameters:
      utcTime - UTC time to be formatted.
      zoneId -
      Returns:
      ET formatted time.
    • toLocalDateTime

      public static LocalDateTime toLocalDateTime(long epochTs)
    • toLocalDateTime

      public static LocalDateTime toLocalDateTime(long epochTs, ZoneId zoneId)
    • toOffsetDateTime

      public static OffsetDateTime toOffsetDateTime(long epochTs, ZoneId zoneId)
    • toOffsetDateTime

      public static OffsetDateTime toOffsetDateTime(LocalDate localDate, ZoneId zoneId)
    • toZonedDateTime

      public static ZonedDateTime toZonedDateTime(LocalDate localDate, ZoneId zoneId)
    • random

      public static int random(int low, int high)
    • truncatedExponentialBackoffSlots

      public static double truncatedExponentialBackoffSlots(int retry, int truncatedMaxRetry)
      expected backoff time = random value between (2^n - 1)/2 and (2^n - 1), n should be truncated by max retry. For the example, E(3) = 3.5 slots, the expected backoff slots should between 3 ~ 7 slots
      Parameters:
      retry - the (n)th retry
      truncatedMaxRetry - stop(truncate) exponential backoff when after truncatedMax retry
      Returns:
      the expected backoff slots