Class TimeHelper


  • public final class TimeHelper
    extends Object
    Helpers for classes in java.time.*
    • Method Detail

      • parseZoneDateTime

        public static ZonedDateTime parseZoneDateTime​(String value,
                                                      DateTimeFormatter formatter)
        Workaround for https://bugs.openjdk.java.net/browse/JDK-8066982, which at the moment has only been solved for JDK9.

        Tested against TCKDTFParsedInstant in http://hg.openjdk.java.net/jdk9/dev/jdk/rev/f371bdfb7875 with both JDK8b101 and JDK9 (early access - build 137).

        Parameters:
        value - The value to be parsed
        formatter - The formatter to use when parsing
        Returns:
        The parsed ZonedDateTime
      • toMillisecondsRoundedUp

        public static Long toMillisecondsRoundedUp​(Long time,
                                                   TimeUnit timeUnit)
        Converts in milliseconds a time duration expressed with time and timeUnit. The result value is rounded up. If either of the parameters is null, it will return null.
        Parameters:
        time - a time duration
        timeUnit - the time unit used to express the duration
        Returns:
        rounded up duration in milliseconds