Class DateFormatters

java.lang.Object
org.elasticsearch.common.time.DateFormatters

public class DateFormatters extends Object
  • Field Details

    • WEEK_FIELDS_ROOT

      public static final WeekFields WEEK_FIELDS_ROOT
  • Constructor Details

    • DateFormatters

      public DateFormatters()
  • Method Details

    • from

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

      public static ZonedDateTime from(TemporalAccessor accessor, Locale locale, ZoneId defaultZone)