Class DateFormatters
- Opensearch.internal:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DateFormatter
Returns RFC 3339 a popular ISO 8601 profile compatible date time formatter and parser.static final WeekFields
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ZonedDateTime
from
(TemporalAccessor accessor) Convert a temporal accessor to a zoned date time object - as performant as possible.static ZonedDateTime
from
(TemporalAccessor accessor, Locale locale) static ZonedDateTime
from
(TemporalAccessor accessor, Locale locale, ZoneId defaultZone)
-
Field Details
-
WEEK_FIELDS_ROOT
-
RFC3339_LENIENT_DATE_FORMATTER
Returns RFC 3339 a popular ISO 8601 profile compatible date time formatter and parser. This is not fully compatible to the existing spec, its more linient and closely follows w3c note on datetime
-
-
Constructor Details
-
DateFormatters
public DateFormatters()
-
-
Method Details
-
from
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 accordinglyThis 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
-
from
-