Package org.summerboot.jexpress.util
Class TimeUtil
java.lang.Object
org.summerboot.jexpress.util.TimeUtil
- Author:
- Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic DateTimeFormatterprotected static Randomstatic DateTimeFormatterstatic ZoneId -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longstatic longstatic intrandom(int low, int high) static int[]seconds2DHMS(long totalSeconds) static Stringseconds2DHMSString(long totalSeconds) static LocalDateTimetoLocalDateTime(long utcTs) static LocalDateTimetoLocalDateTime(long utcTs, ZoneId zoneId) static OffsetDateTimetoOffsetDateTime(long utcTs, ZoneId zoneId) static doubletruncatedExponentialBackoffSlots(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.static StringutcDateTimeToLocalDateTime(String utcTime, ZoneId zoneId) Maps the UTC time to an ET format.
-
Field Details
-
ISO_ZONED_DATE_TIME3
-
UTC_DATE_TIME_FORMATTER
-
ZONE_ID_ONTARIO
-
RANDOM
-
-
Constructor Details
-
TimeUtil
public TimeUtil()
-
-
Method Details
-
getSecondsSinceMidnight
-
getSecondsTillMidnight
-
seconds2DHMS
public static int[] seconds2DHMS(long totalSeconds) -
seconds2DHMSString
-
utcDateTimeToLocalDateTime
Maps the UTC time to an ET format.- Parameters:
utcTime- UTC time to be formatted.zoneId-- Returns:
- ET formatted time.
-
toLocalDateTime
-
toLocalDateTime
-
toOffsetDateTime
-
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 retrytruncatedMaxRetry- stop(truncate) exponential backoff when after truncatedMax retry- Returns:
- the expected backoff slots
-