Class DateFormatters

org.elasticsearch.common.time.DateFormatters

public class DateFormatters extends
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static
     accessor)
    Convert a temporal accessor to a zoned date time object - as performant as possible.
    static
     accessor,  locale)
     
    static
     accessor,  locale,  defaultZone)
     

    Methods inherited from class java.lang.

    , , , , , , , , , ,
  • Field Details

    • WEEK_FIELDS_ROOT

      public static final  WEEK_FIELDS_ROOT
  • Constructor Details

    • DateFormatters

      public DateFormatters()
  • Method Details

    • from

      public static  from( 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  from( accessor,  locale)
    • from

      public static  from( accessor,  locale,  defaultZone)