Class DateFormatters


  • public class DateFormatters
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      DateFormatters()  
    • Method Summary

      Modifier and Type Method Description
      static DateFormatter forPattern​(java.lang.String input)  
      static java.time.ZonedDateTime from​(java.time.temporal.TemporalAccessor accessor)
      Convert a temporal accessor to a zoned date time object - as performant as possible.
      static java.time.ZonedDateTime from​(java.time.temporal.TemporalAccessor accessor, java.util.Locale locale)  
      static java.time.ZonedDateTime from​(java.time.temporal.TemporalAccessor accessor, java.util.Locale locale, java.time.ZoneId defaultZone)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DateFormatters

        public DateFormatters()
    • Method Detail

      • forPattern

        public static DateFormatter forPattern​(java.lang.String input)
      • from

        public static java.time.ZonedDateTime from​(java.time.temporal.TemporalAccessor accessor)
        Convert a temporal accessor to a zoned date time object - as performant as possible. The .from() methods from the JDK are throwing exceptions when for example ZonedDateTime.from(accessor) or Instant.from(accessor). This results in a huge performance penalty and should be prevented This method prevents exceptions by querying the accessor for certain capabilities and then act on it accordingly This action assumes that we can reliably fall back to some defaults if not all parts of a zoned date time are set - If a zoned date time is passed, it is returned - If no timezone is found, ZoneOffset.UTC is used - If we find a time and a date, converting to a ZonedDateTime is straight forward, no defaults will be applied - If an accessor only containing of seconds and nanos is found (like epoch_millis/second) an Instant is created out of that, that becomes a ZonedDateTime with a time zone - If no time is given, the start of the day is used - If no month of the year is found, the first day of the year is used - If an iso based weekyear is found, but not week is specified, the first monday of the new year is chosen (reataining BWC to joda time) - If an iso based weekyear is found and an iso based weekyear week, the start of the day is used
        Parameters:
        accessor - The accessor returned from a parser
        Returns:
        The converted zoned date time
      • from

        public static java.time.ZonedDateTime from​(java.time.temporal.TemporalAccessor accessor,
                                                   java.util.Locale locale)
      • from

        public static java.time.ZonedDateTime from​(java.time.temporal.TemporalAccessor accessor,
                                                   java.util.Locale locale,
                                                   java.time.ZoneId defaultZone)