DateTimeFormatterBuilder

Builder to create date-time formatters. !(p) This allows a {@code DateTimeFormatter} to be created. All date-time formatters are created ultimately using this builder. !(p) The basic elements of date-time can all be added: !(ul) !(li)Value - a numeric value</li> !(li)Fraction - a fractional value including the decimal place. Always use this when outputting fractions to ensure that the fraction is parsed correctly</li> !(li)Text - the textual equivalent for the value</li> !(li)OffsetId/Offset - the {@linkplain ZoneOffset zone offset}</li> !(li)ZoneId - the {@linkplain ZoneId time-zone} id</li> !(li)ZoneText - the name of the time-zone</li> !(li)ChronologyId - the {@linkplain Chronology chronology} id</li> !(li)ChronologyText - the name of the chronology</li> !(li)Literal - a text literal</li> !(li)Nested and Optional - formats can be nested or made optional</li> </ul> In addition, any of the elements may be decorated by padding, either with spaces or any other character. !(p) Finally, a shorthand pattern, mostly compatible with {@code java.text.SimpleDateFormat SimpleDateFormat} can be used, see {@link #appendPattern(string)}. In practice, this simply parses the pattern and calls other methods on the builder.

@implSpec This class is a mutable builder intended for use from a single thread.

@since 1.8

final
class DateTimeFormatterBuilder {}

Constructors

this
this()

Constructs a new instance of the builder.

Members

Functions

active
DateTimeFormatterBuilder active()
Undocumented in source. Be warned that the author may not have intended to support it.
append
DateTimeFormatterBuilder append(DateTimeFormatter formatter)

Appends all the elements of a formatter to the builder. !(p) This method has the same effect as appending each of the constituent parts of the formatter directly to this builder.

appendChronologyId
DateTimeFormatterBuilder appendChronologyId()

Appends the chronology ID, such as 'ISO' or 'ThaiBuddhist', to the formatter. !(p) This appends an instruction to format/parse the chronology ID to the builder. !(p) During formatting, the chronology is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#chronology()}. It will be printed using the result of {@link Chronology#getId()}. If the chronology cannot be obtained then an exception is thrown unless the section of the formatter is optional. !(p) During parsing, the chronology is parsed and must match one of the chronologies _in {@link Chronology#getAvailableChronologies()}. If the chronology cannot be parsed then an exception is thrown unless the section of the formatter is optional. The parser uses the {@linkplain #parseCaseInsensitive() case sensitive} setting.

appendChronologyText
DateTimeFormatterBuilder appendChronologyText(TextStyle textStyle)

Appends the chronology name to the formatter. !(p) The calendar system name will be output during a format. If the chronology cannot be obtained then an exception will be thrown.

appendFraction
DateTimeFormatterBuilder appendFraction(TemporalField field, int minWidth, int maxWidth, bool decimalPoint)

Appends the fractional value of a date-time field to the formatter. !(p) The fractional value of the field will be output including the preceding decimal point. The preceding value is not output. For example, the second-of-minute value of 15 would be output as {@code .25}. !(p) The width of the printed fraction can be controlled. Setting the minimum width to zero will cause no output to be generated. The printed fraction will have the minimum width necessary between the minimum and maximum widths - trailing zeroes are omitted. No rounding occurs due to the maximum width - digits are simply dropped. !(p) When parsing _in strict mode, the number of parsed digits must be between the minimum and maximum width. In strict mode, if the minimum and maximum widths are equal and there is no decimal point then the parser will participate _in adjacent value parsing, see {@link appendValue(hunt.time.temporal.TemporalField, int)}. When parsing _in lenient mode, the minimum width is considered to be zero and the maximum is nine. !(p) If the value cannot be obtained then an exception will be thrown. If the value is negative an exception will be thrown. If the field does not have a fixed set of valid values then an exception will be thrown. If the field value _in the date-time to be printed is invalid it cannot be printed and an exception will be thrown.

appendGenericZoneText
DateTimeFormatterBuilder appendGenericZoneText(TextStyle textStyle)

Appends the generic time-zone name, such as 'Pacific Time', to the formatter. !(p) This appends an instruction to format/parse the generic textual name of the zone to the builder. The generic name is the same throughout the whole year, ignoring any daylight saving changes. For example, 'Pacific Time' is the generic name, whereas 'Pacific Standard Time' and 'Pacific Daylight Time' are the specific names, see {@link #appendZoneText(TextStyle)}. !(p) During formatting, the zone is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#zoneId()}. If the zone is a {@code ZoneOffset} it will be printed using the result of {@link ZoneOffset#getId()}. If the zone is not an offset, the textual name will be looked up for the locale set _in the {@link DateTimeFormatter}. If the lookup for text does not find any suitable result, then the {@link ZoneId#getId() ID} will be printed. If the zone cannot be obtained then an exception is thrown unless the section of the formatter is optional. !(p) During parsing, either the textual zone name, the zone ID or the offset is accepted. Many textual zone names are not unique, such as CST can be for both "Central Standard Time" and "China Standard Time". In this situation, the zone id will be determined by the region information from formatter's {@link DateTimeFormatter#getLocale() locale} and the standard zone id for that area, for example, America/New_York for the America Eastern zone. The {@link #appendGenericZoneText(TextStyle, Set)} may be used to specify a set of preferred {@link ZoneId} _in this situation.

appendGenericZoneText
DateTimeFormatterBuilder appendGenericZoneText(TextStyle textStyle, Set!(ZoneId) preferredZones)

Appends the generic time-zone name, such as 'Pacific Time', to the formatter. !(p) This appends an instruction to format/parse the generic textual name of the zone to the builder. The generic name is the same throughout the whole year, ignoring any daylight saving changes. For example, 'Pacific Time' is the generic name, whereas 'Pacific Standard Time' and 'Pacific Daylight Time' are the specific names, see {@link #appendZoneText(TextStyle)}. !(p) This method also allows a set of preferred {@link ZoneId} to be specified for parsing. The matched preferred zone id will be used if the textural zone name being parsed is not unique. !(p) See {@link #appendGenericZoneText(TextStyle)} for details about formatting and parsing.

appendInstant
DateTimeFormatterBuilder appendInstant()

Appends an instant using ISO-8601 to the formatter, formatting fractional digits _in groups of three. !(p) Instants have a fixed output format. They are converted to a date-time with a zone-offset of UTC and formatted using the standard ISO-8601 format. With this method, formatting nano-of-second outputs zero, three, six or nine digits as necessary. The localized decimal style is not used. !(p) The instant is obtained using {@link ChronoField#INSTANT_SECONDS INSTANT_SECONDS} and optionally {@code NANO_OF_SECOND}. The value of {@code INSTANT_SECONDS} may be outside the maximum range of {@code LocalDateTime}. !(p) The {@linkplain ResolverStyle resolver style} has no effect on instant parsing. The end-of-day time of '24:00' is handled as midnight at the start of the following day. The leap-second time of '23:59:59' is handled to some degree, see {@link DateTimeFormatter#parsedLeapSecond()} for full details. !(p) When formatting, the instant will always be suffixed by 'Z' to indicate UTC. When parsing, the behaviour of {@link DateTimeFormatterBuilder#appendOffsetId()} will be used to parse the offset, converting the instant to UTC as necessary. !(p) An alternative to this method is to format/parse the instant as a single epoch-seconds value. That is achieved using {@code appendValue(INSTANT_SECONDS)}.

appendInstant
DateTimeFormatterBuilder appendInstant(int fractionalDigits)

Appends an instant using ISO-8601 to the formatter with control over the number of fractional digits. !(p) Instants have a fixed output format, although this method provides some control over the fractional digits. They are converted to a date-time with a zone-offset of UTC and printed using the standard ISO-8601 format. The localized decimal style is not used. !(p) The {@code fractionalDigits} parameter allows the output of the fractional second to be controlled. Specifying zero will cause no fractional digits to be output. From 1 to 9 will output an increasing number of digits, using zero right-padding if necessary. The special value -1 is used to output as many digits as necessary to avoid any trailing zeroes. !(p) When parsing _in strict mode, the number of parsed digits must match the fractional digits. When parsing _in lenient mode, any number of fractional digits from zero to nine are accepted. !(p) The instant is obtained using {@link ChronoField#INSTANT_SECONDS INSTANT_SECONDS} and optionally {@code NANO_OF_SECOND}. The value of {@code INSTANT_SECONDS} may be outside the maximum range of {@code LocalDateTime}. !(p) The {@linkplain ResolverStyle resolver style} has no effect on instant parsing. The end-of-day time of '24:00' is handled as midnight at the start of the following day. The leap-second time of '23:59:60' is handled to some degree, see {@link DateTimeFormatter#parsedLeapSecond()} for full details. !(p) An alternative to this method is to format/parse the instant as a single epoch-seconds value. That is achieved using {@code appendValue(INSTANT_SECONDS)}.

appendLiteral
DateTimeFormatterBuilder appendLiteral(char literal)

Appends a character literal to the formatter. !(p) This character will be output during a format.

appendLiteral
DateTimeFormatterBuilder appendLiteral(string literal)

Appends a string literal to the formatter. !(p) This string will be output during a format. !(p) If the literal is empty, nothing is added to the formatter.

appendLocalized
DateTimeFormatterBuilder appendLocalized(FormatStyle dateStyle, FormatStyle timeStyle)

Appends a localized date-time pattern to the formatter. !(p) This appends a localized section to the builder, suitable for outputting a date, time or date-time combination. The format of the localized section is lazily looked up based on four items: !(ul) !(li)the {@code dateStyle} specified to this method !(li)the {@code timeStyle} specified to this method !(li)the {@code Locale} of the {@code DateTimeFormatter} !(li)the {@code Chronology}, selecting the best available </ul> During formatting, the chronology is obtained from the temporal object being formatted, which may have been overridden by {@link DateTimeFormatter#withChronology(Chronology)}. The {@code FULL} and {@code LONG} styles typically require a time-zone. When formatting using these styles, a {@code ZoneId} must be available, either by using {@code ZonedDateTime} or {@link DateTimeFormatter#withZone}. !(p) During parsing, if a chronology has already been parsed, then it is used. Otherwise the default from {@code DateTimeFormatter.withChronology(Chronology)} is used, with {@code IsoChronology} as the fallback. !(p) Note that this method provides similar functionality to methods on {@code DateFormat} such as {@link java.text.DateFormat#getDateTimeInstance(int, int)}.

appendLocalizedOffset
DateTimeFormatterBuilder appendLocalizedOffset(TextStyle style)

Appends the localized zone offset, such as 'GMT+01:00', to the formatter. !(p) This appends a localized zone offset to the builder, the format of the localized offset is controlled by the specified {@link FormatStyle style} to this method: !(ul) !(li){@link TextStyle#FULL full} - formats with localized offset text, such as 'GMT, 2-digit hour and minute field, optional second field if non-zero, and colon. !(li){@link TextStyle#SHORT short} - formats with localized offset text, such as 'GMT, hour without leading zero, optional 2-digit minute and second if non-zero, and colon. </ul> !(p) During formatting, the offset is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#offset()}. If the offset cannot be obtained then an exception is thrown unless the section of the formatter is optional. !(p) During parsing, the offset is parsed using the format defined above. If the offset cannot be parsed then an exception is thrown unless the section of the formatter is optional.

appendOffset
DateTimeFormatterBuilder appendOffset(string pattern, string noOffsetText)

Appends the zone offset, such as '+01:00', to the formatter. !(p) This appends an instruction to format/parse the offset ID to the builder. !(p) During formatting, the offset is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#offset()}. It will be printed using the format defined below. If the offset cannot be obtained then an exception is thrown unless the section of the formatter is optional. !(p) When parsing _in strict mode, the input must contain the mandatory and optional elements are defined by the specified pattern. If the offset cannot be parsed then an exception is thrown unless the section of the formatter is optional. !(p) When parsing _in lenient mode, only the hours are mandatory - minutes and seconds are optional. The colons are required if the specified pattern contains a colon. If the specified pattern is "+HH", the presence of colons is determined by whether the character after the hour digits is a colon or not. If the offset cannot be parsed then an exception is thrown unless the section of the formatter is optional. !(p) The format of the offset is controlled by a pattern which must be one of the following: !(ul) !(li){@code +HH} - hour only, ignoring minute and second !(li){@code +HHmm} - hour, with minute if non-zero, ignoring second, no colon !(li){@code +HH:mm} - hour, with minute if non-zero, ignoring second, with colon !(li){@code +HHMM} - hour and minute, ignoring second, no colon !(li){@code +HH:MM} - hour and minute, ignoring second, with colon !(li){@code +HHMMss} - hour and minute, with second if non-zero, no colon !(li){@code +HH:MM:ss} - hour and minute, with second if non-zero, with colon !(li){@code +HHMMSS} - hour, minute and second, no colon !(li){@code +HH:MM:SS} - hour, minute and second, with colon !(li){@code +HHmmss} - hour, with minute if non-zero or with minute and second if non-zero, no colon !(li){@code +HH:mm:ss} - hour, with minute if non-zero or with minute and second if non-zero, with colon !(li){@code +H} - hour only, ignoring minute and second !(li){@code +Hmm} - hour, with minute if non-zero, ignoring second, no colon !(li){@code +H:mm} - hour, with minute if non-zero, ignoring second, with colon !(li){@code +HMM} - hour and minute, ignoring second, no colon !(li){@code +H:MM} - hour and minute, ignoring second, with colon !(li){@code +HMMss} - hour and minute, with second if non-zero, no colon !(li){@code +H:MM:ss} - hour and minute, with second if non-zero, with colon !(li){@code +HMMSS} - hour, minute and second, no colon !(li){@code +H:MM:SS} - hour, minute and second, with colon !(li){@code +Hmmss} - hour, with minute if non-zero or with minute and second if non-zero, no colon !(li){@code +H:mm:ss} - hour, with minute if non-zero or with minute and second if non-zero, with colon </ul> Patterns containing "HH" will format and parse a two digit hour, zero-padded if necessary. Patterns containing "H" will format with no zero-padding, and parse either one or two digits. In lenient mode, the parser will be greedy and parse the maximum digits possible. The "no offset" text controls what text is printed when the total amount of the offset fields to be output is zero. Example values would be 'Z', '+00:00', 'UTC' or 'GMT'. Three formats are accepted for parsing UTC - the "no offset" text, and the plus and minus versions of zero defined by the pattern.

appendOffsetId
DateTimeFormatterBuilder appendOffsetId()

Appends the zone offset, such as '+01:00', to the formatter. !(p) This appends an instruction to format/parse the offset ID to the builder. This is equivalent to calling {@code appendOffset("+HH:mm:ss", "Z")}. See {@link #appendOffset(string, string)} for details on formatting and parsing.

appendOptional
DateTimeFormatterBuilder appendOptional(DateTimeFormatter formatter)

Appends a formatter to the builder which will optionally format/parse. !(p) This method has the same effect as appending each of the constituent parts directly to this builder surrounded by an {@link #optionalStart()} and {@link #optionalEnd()}. !(p) The formatter will format if data is available for all the fields contained within it. The formatter will parse if the string matches, otherwise no error is returned.

appendPattern
DateTimeFormatterBuilder appendPattern(string pattern)

Appends the elements defined by the specified pattern to the builder. !(p) All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The characters '#', '{' and '}' are reserved for future use. The characters '[' and ']' indicate optional patterns. The following pattern letters are defined: !(pre) Symbol Meaning Presentation Examples

appendText
DateTimeFormatterBuilder appendText(TemporalField field)

Appends the text of a date-time field to the formatter using the full text style. !(p) The text of the field will be output during a format. The value must be within the valid range of the field. If the value cannot be obtained then an exception will be thrown. If the field has no textual representation, then the numeric value will be used. !(p) The value will be printed as per the normal format of an integer value. Only negative numbers will be signed. No padding will be added.

appendText
DateTimeFormatterBuilder appendText(TemporalField field, TextStyle textStyle)

Appends the text of a date-time field to the formatter. !(p) The text of the field will be output during a format. The value must be within the valid range of the field. If the value cannot be obtained then an exception will be thrown. If the field has no textual representation, then the numeric value will be used. !(p) The value will be printed as per the normal format of an integer value. Only negative numbers will be signed. No padding will be added.

appendText
DateTimeFormatterBuilder appendText(TemporalField field, Map!(Long, string) textLookup)

Appends the text of a date-time field to the formatter using the specified map to supply the text. !(p) The standard text outputting methods use the localized text _in the JDK. This method allows that text to be specified directly. The supplied map is not validated by the builder to ensure that formatting or parsing is possible, thus an invalid map may throw an error during later use. !(p) Supplying the map of text provides considerable flexibility _in formatting and parsing. For example, a legacy application might require or supply the months of the year as "JNY", "FBY", "MCH" etc. These do not match the standard set of text for localized month names. Using this method, a map can be created which defines the connection between each value and the text: !(pre) Map&lt;Long, string&gt; map = new HashMap&lt;&gt;(); map.put(1L, "JNY"); map.put(2L, "FBY"); map.put(3L, "MCH"); ... builder.appendText(MONTH_OF_YEAR, map); </pre> !(p) Other uses might be to output the value with a suffix, such as "1st", "2nd", "3rd", or as Roman numerals "I", "II", "III", "IV". !(p) During formatting, the value is obtained and checked that it is _in the valid range. If text is not available for the value then it is output as a number. During parsing, the parser will match against the map of text and numeric values.

appendValue
DateTimeFormatterBuilder appendValue(TemporalField field)

Appends the value of a date-time field to the formatter using a normal output style. !(p) The value of the field will be output during a format. If the value cannot be obtained then an exception will be thrown. !(p) The value will be printed as per the normal format of an integer value. Only negative numbers will be signed. No padding will be added. !(p) The parser for a variable width value such as this normally behaves greedily, requiring one digit, but accepting as many digits as possible. This behavior can be affected by 'adjacent value parsing'. See {@link #appendValue(hunt.time.temporal.TemporalField, int)} for full details.

appendValue
DateTimeFormatterBuilder appendValue(TemporalField field, int width)

Appends the value of a date-time field to the formatter using a fixed width, zero-padded approach. !(p) The value of the field will be output during a format. If the value cannot be obtained then an exception will be thrown. !(p) The value will be zero-padded on the left. If the size of the value means that it cannot be printed within the width then an exception is thrown. If the value of the field is negative then an exception is thrown during formatting. !(p) This method supports a special technique of parsing known as 'adjacent value parsing'. This technique solves the problem where a value, variable or fixed width, is followed by one or more fixed length values. The standard parser is greedy, and thus it would normally steal the digits that are needed by the fixed width value parsers that follow the variable width one. !(p) No action is required to initiate 'adjacent value parsing'. When a call to {@code appendValue} is made, the builder enters adjacent value parsing setup mode. If the immediately subsequent method call or calls on the same builder are for a fixed width value, then the parser will reserve space so that the fixed width values can be parsed. !(p) For example, consider {@code builder.appendValue(YEAR).appendValue(MONTH_OF_YEAR, 2);} The year is a variable width parse of between 1 and 19 digits. The month is a fixed width parse of 2 digits. Because these were appended to the same builder immediately after one another, the year parser will reserve two digits for the month to parse. Thus, the text '201106' will correctly parse to a year of 2011 and a month of 6. Without adjacent value parsing, the year would greedily parse all six digits and leave nothing for the month. !(p) Adjacent value parsing applies to each set of fixed width not-negative values _in the parser that immediately follow any kind of value, variable or fixed width. Calling any other append method will end the setup of adjacent value parsing. Thus, _in the unlikely event that you need to avoid adjacent value parsing behavior, simply add the {@code appendValue} to another {@code DateTimeFormatterBuilder} and add that to this builder. !(p) If adjacent parsing is active, then parsing must match exactly the specified number of digits _in both strict and lenient modes. In addition, no positive or negative sign is permitted.

appendValue
DateTimeFormatterBuilder appendValue(TemporalField field, int minWidth, int maxWidth, SignStyle signStyle)

Appends the value of a date-time field to the formatter providing full control over formatting. !(p) The value of the field will be output during a format. If the value cannot be obtained then an exception will be thrown. !(p) This method provides full control of the numeric formatting, including zero-padding and the positive/negative sign. !(p) The parser for a variable width value such as this normally behaves greedily, accepting as many digits as possible. This behavior can be affected by 'adjacent value parsing'. See {@link #appendValue(hunt.time.temporal.TemporalField, int)} for full details. !(p) In strict parsing mode, the minimum number of parsed digits is {@code minWidth} and the maximum is {@code maxWidth}. In lenient parsing mode, the minimum number of parsed digits is one and the maximum is 19 (except as limited by adjacent value parsing). !(p) If this method is invoked with equal minimum and maximum widths and a sign style of {@code NOT_NEGATIVE} then it delegates to {@code appendValue(TemporalField,int)}. In this scenario, the formatting and parsing behavior described there occur.

appendValueReduced
DateTimeFormatterBuilder appendValueReduced(TemporalField field, int width, int maxWidth, int baseValue)

Appends the reduced value of a date-time field to the formatter. !(p) Since fields such as year vary by chronology, it is recommended to use the {@link #appendValueReduced(TemporalField, int, int, ChronoLocalDate)} date} variant of this method _in most cases. This variant is suitable for simple fields or working with only the ISO chronology. !(p) For formatting, the {@code width} and {@code maxWidth} are used to determine the number of characters to format. If they are equal then the format is fixed width. If the value of the field is within the range of the {@code baseValue} using {@code width} characters then the reduced value is formatted otherwise the value is truncated to fit {@code maxWidth}. The rightmost characters are output to match the width, left padding with zero. !(p) For strict parsing, the number of characters allowed by {@code width} to {@code maxWidth} are parsed. For lenient parsing, the number of characters must be at least 1 and less than 10. If the number of digits parsed is equal to {@code width} and the value is positive, the value of the field is computed to be the first number greater than or equal to the {@code baseValue} with the same least significant characters, otherwise the value parsed is the field value. This allows a reduced value to be entered for values _in range of the baseValue and width and absolute values can be entered for values outside the range. !(p) For example, a base value of {@code 1980} and a width of {@code 2} will have valid values from {@code 1980} to {@code 2079}. During parsing, the text {@code "12"} will result _in the value {@code 2012} as that is the value within the range where the last two characters are "12". By contrast, parsing the text {@code "1915"} will result _in the value {@code 1915}.

appendValueReduced
DateTimeFormatterBuilder appendValueReduced(TemporalField field, int width, int maxWidth, ChronoLocalDate baseDate)

Appends the reduced value of a date-time field to the formatter. !(p) This is typically used for formatting and parsing a two digit year. !(p) The base date is used to calculate the full value during parsing. For example, if the base date is 1950-01-01 then parsed values for a two digit year parse will be _in the range 1950-01-01 to 2049-12-31. Only the year would be extracted from the date, thus a base date of 1950-08-25 would also parse to the range 1950-01-01 to 2049-12-31. This behavior is necessary to support fields such as week-based-year or other calendar systems where the parsed value does not align with standard ISO years. !(p) The exact behavior is as follows. Parse the full set of fields and determine the effective chronology using the last chronology if it appears more than once. Then convert the base date to the effective chronology. Then extract the specified field from the chronology-specific base date and use it to determine the {@code baseValue} used below. !(p) For formatting, the {@code width} and {@code maxWidth} are used to determine the number of characters to format. If they are equal then the format is fixed width. If the value of the field is within the range of the {@code baseValue} using {@code width} characters then the reduced value is formatted otherwise the value is truncated to fit {@code maxWidth}. The rightmost characters are output to match the width, left padding with zero. !(p) For strict parsing, the number of characters allowed by {@code width} to {@code maxWidth} are parsed. For lenient parsing, the number of characters must be at least 1 and less than 10. If the number of digits parsed is equal to {@code width} and the value is positive, the value of the field is computed to be the first number greater than or equal to the {@code baseValue} with the same least significant characters, otherwise the value parsed is the field value. This allows a reduced value to be entered for values _in range of the baseValue and width and absolute values can be entered for values outside the range. !(p) For example, a base value of {@code 1980} and a width of {@code 2} will have valid values from {@code 1980} to {@code 2079}. During parsing, the text {@code "12"} will result _in the value {@code 2012} as that is the value within the range where the last two characters are "12". By contrast, parsing the text {@code "1915"} will result _in the value {@code 1915}.

appendZoneId
DateTimeFormatterBuilder appendZoneId()

Appends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter. !(p) This appends an instruction to format/parse the zone ID to the builder. The zone ID is obtained _in a strict manner suitable for {@code ZonedDateTime}. By contrast, {@code OffsetDateTime} does not have a zone ID suitable for use with this method, see {@link #appendZoneOrOffsetId()}. !(p) During formatting, the zone is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#zoneId()}. It will be printed using the result of {@link ZoneId#getId()}. If the zone cannot be obtained then an exception is thrown unless the section of the formatter is optional. !(p) During parsing, the text must match a known zone or offset. There are two types of zone ID, offset-based, such as '+01:30' and region-based, such as 'Europe/London'. These are parsed differently. If the parse starts with '+', '-', 'UT', 'UTC' or 'GMT', then the parser expects an offset-based zone and will not match region-based zones. The offset ID, such as '+02:30', may be at the start of the parse, or prefixed by 'UT', 'UTC' or 'GMT'. The offset ID parsing is equivalent to using {@link #appendOffset(string, string)} using the arguments 'HH:MM:ss' and the no offset string '0'. If the parse starts with 'UT', 'UTC' or 'GMT', and the parser cannot match a following offset ID, then {@link ZoneOffset#UTC} is selected. In all other cases, the list of known region-based zones is used to find the longest available match. If no match is found, and the parse starts with 'Z', then {@code ZoneOffset.UTC} is selected. The parser uses the {@linkplain #parseCaseInsensitive() case sensitive} setting. !(p) For example, the following will parse: !(pre) "Europe/London" -- ZoneId.of("Europe/London") "Z" -- ZoneOffset.UTC "UT" -- ZoneId.of("UT") "UTC" -- ZoneId.of("UTC") "GMT" -- ZoneId.of("GMT") "+01:30" -- ZoneOffset.of("+01:30") "UT+01:30" -- ZoneOffset.of("+01:30") "UTC+01:30" -- ZoneOffset.of("+01:30") "GMT+01:30" -- ZoneOffset.of("+01:30") </pre>

appendZoneOrOffsetId
DateTimeFormatterBuilder appendZoneOrOffsetId()

Appends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter, using the best available zone ID. !(p) This appends an instruction to format/parse the best available zone or offset ID to the builder. The zone ID is obtained _in a lenient manner that first attempts to find a true zone ID, such as that on {@code ZonedDateTime}, and then attempts to find an offset, such as that on {@code OffsetDateTime}. !(p) During formatting, the zone is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#zone()}. It will be printed using the result of {@link ZoneId#getId()}. If the zone cannot be obtained then an exception is thrown unless the section of the formatter is optional. !(p) During parsing, the text must match a known zone or offset. There are two types of zone ID, offset-based, such as '+01:30' and region-based, such as 'Europe/London'. These are parsed differently. If the parse starts with '+', '-', 'UT', 'UTC' or 'GMT', then the parser expects an offset-based zone and will not match region-based zones. The offset ID, such as '+02:30', may be at the start of the parse, or prefixed by 'UT', 'UTC' or 'GMT'. The offset ID parsing is equivalent to using {@link #appendOffset(string, string)} using the arguments 'HH:MM:ss' and the no offset string '0'. If the parse starts with 'UT', 'UTC' or 'GMT', and the parser cannot match a following offset ID, then {@link ZoneOffset#UTC} is selected. In all other cases, the list of known region-based zones is used to find the longest available match. If no match is found, and the parse starts with 'Z', then {@code ZoneOffset.UTC} is selected. The parser uses the {@linkplain #parseCaseInsensitive() case sensitive} setting. !(p) For example, the following will parse: !(pre) "Europe/London" -- ZoneId.of("Europe/London") "Z" -- ZoneOffset.UTC "UT" -- ZoneId.of("UT") "UTC" -- ZoneId.of("UTC") "GMT" -- ZoneId.of("GMT") "+01:30" -- ZoneOffset.of("+01:30") "UT+01:30" -- ZoneOffset.of("UT+01:30") "UTC+01:30" -- ZoneOffset.of("UTC+01:30") "GMT+01:30" -- ZoneOffset.of("GMT+01:30") </pre> !(p) Note that this method is identical to {@code appendZoneId()} except _in the mechanism used to obtain the zone.

appendZoneRegionId
DateTimeFormatterBuilder appendZoneRegionId()

Appends the time-zone region ID, such as 'Europe/Paris', to the formatter, rejecting the zone ID if it is a {@code ZoneOffset}. !(p) This appends an instruction to format/parse the zone ID to the builder only if it is a region-based ID. !(p) During formatting, the zone is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#zoneId()}. If the zone is a {@code ZoneOffset} or it cannot be obtained then an exception is thrown unless the section of the formatter is optional. If the zone is not an offset, then the zone will be printed using the zone ID from {@link ZoneId#getId()}. !(p) During parsing, the text must match a known zone or offset. There are two types of zone ID, offset-based, such as '+01:30' and region-based, such as 'Europe/London'. These are parsed differently. If the parse starts with '+', '-', 'UT', 'UTC' or 'GMT', then the parser expects an offset-based zone and will not match region-based zones. The offset ID, such as '+02:30', may be at the start of the parse, or prefixed by 'UT', 'UTC' or 'GMT'. The offset ID parsing is equivalent to using {@link #appendOffset(string, string)} using the arguments 'HH:MM:ss' and the no offset string '0'. If the parse starts with 'UT', 'UTC' or 'GMT', and the parser cannot match a following offset ID, then {@link ZoneOffset#UTC} is selected. In all other cases, the list of known region-based zones is used to find the longest available match. If no match is found, and the parse starts with 'Z', then {@code ZoneOffset.UTC} is selected. The parser uses the {@linkplain #parseCaseInsensitive() case sensitive} setting. !(p) For example, the following will parse: !(pre) "Europe/London" -- ZoneId.of("Europe/London") "Z" -- ZoneOffset.UTC "UT" -- ZoneId.of("UT") "UTC" -- ZoneId.of("UTC") "GMT" -- ZoneId.of("GMT") "+01:30" -- ZoneOffset.of("+01:30") "UT+01:30" -- ZoneOffset.of("+01:30") "UTC+01:30" -- ZoneOffset.of("+01:30") "GMT+01:30" -- ZoneOffset.of("+01:30") </pre> !(p) Note that this method is identical to {@code appendZoneId()} except _in the mechanism used to obtain the zone. Note also that parsing accepts offsets, whereas formatting will never produce one.

appendZoneText
DateTimeFormatterBuilder appendZoneText(TextStyle textStyle)

Appends the time-zone name, such as 'British Summer Time', to the formatter. !(p) This appends an instruction to format/parse the textual name of the zone to the builder. !(p) During formatting, the zone is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#zoneId()}. If the zone is a {@code ZoneOffset} it will be printed using the result of {@link ZoneOffset#getId()}. If the zone is not an offset, the textual name will be looked up for the locale set _in the {@link DateTimeFormatter}. If the temporal object being printed represents an instant, or if it is a local date-time that is not _in a daylight saving gap or overlap then the text will be the summer or winter time text as appropriate. If the lookup for text does not find any suitable result, then the {@link ZoneId#getId() ID} will be printed. If the zone cannot be obtained then an exception is thrown unless the section of the formatter is optional. !(p) During parsing, either the textual zone name, the zone ID or the offset is accepted. Many textual zone names are not unique, such as CST can be for both "Central Standard Time" and "China Standard Time". In this situation, the zone id will be determined by the region information from formatter's {@link DateTimeFormatter#getLocale() locale} and the standard zone id for that area, for example, America/New_York for the America Eastern zone. The {@link #appendZoneText(TextStyle, Set)} may be used to specify a set of preferred {@link ZoneId} _in this situation.

appendZoneText
DateTimeFormatterBuilder appendZoneText(TextStyle textStyle, Set!(ZoneId) preferredZones)

Appends the time-zone name, such as 'British Summer Time', to the formatter. !(p) This appends an instruction to format/parse the textual name of the zone to the builder. !(p) During formatting, the zone is obtained using a mechanism equivalent to querying the temporal with {@link TemporalQueries#zoneId()}. If the zone is a {@code ZoneOffset} it will be printed using the result of {@link ZoneOffset#getId()}. If the zone is not an offset, the textual name will be looked up for the locale set _in the {@link DateTimeFormatter}. If the temporal object being printed represents an instant, or if it is a local date-time that is not _in a daylight saving gap or overlap, then the text will be the summer or winter time text as appropriate. If the lookup for text does not find any suitable result, then the {@link ZoneId#getId() ID} will be printed. If the zone cannot be obtained then an exception is thrown unless the section of the formatter is optional. !(p) During parsing, either the textual zone name, the zone ID or the offset is accepted. Many textual zone names are not unique, such as CST can be for both "Central Standard Time" and "China Standard Time". In this situation, the zone id will be determined by the region information from formatter's {@link DateTimeFormatter#getLocale() locale} and the standard zone id for that area, for example, America/New_York for the America Eastern zone. This method also allows a set of preferred {@link ZoneId} to be specified for parsing. The matched preferred zone id will be used if the textural zone name being parsed is not unique. !(p) If the zone cannot be parsed then an exception is thrown unless the section of the formatter is optional.

optionalEnd
DateTimeFormatterBuilder optionalEnd()

Ends an optional section. !(p) The output of formatting can include optional sections, which may be nested. An optional section is started by calling {@link #optionalStart()} and ended using this method (or at the end of the builder). !(p) Calling this method without having previously called {@code optionalStart} will throw an exception. Calling this method immediately after calling {@code optionalStart} has no effect on the formatter other than ending the (empty) optional section. !(p) All elements _in the optional section are treated as optional. During formatting, the section is only output if data is available _in the {@code TemporalAccessor} for all the elements _in the section. During parsing, the whole section may be missing from the parsed string. !(p) For example, consider a builder setup as {@code builder.appendValue(HOUR_OF_DAY,2).optionalStart().appendValue(MINUTE_OF_HOUR,2).optionalEnd()}. During formatting, the minute will only be output if its value can be obtained from the date-time. During parsing, the input will be successfully parsed whether the minute is present or not.

optionalStart
DateTimeFormatterBuilder optionalStart()

Mark the start of an optional section. !(p) The output of formatting can include optional sections, which may be nested. An optional section is started by calling this method and ended by calling {@link #optionalEnd()} or by ending the build process. !(p) All elements _in the optional section are treated as optional. During formatting, the section is only output if data is available _in the {@code TemporalAccessor} for all the elements _in the section. During parsing, the whole section may be missing from the parsed string. !(p) For example, consider a builder setup as {@code builder.appendValue(HOUR_OF_DAY,2).optionalStart().appendValue(MINUTE_OF_HOUR,2)}. The optional section ends automatically at the end of the builder. During formatting, the minute will only be output if its value can be obtained from the date-time. During parsing, the input will be successfully parsed whether the minute is present or not.

padNext
DateTimeFormatterBuilder padNext(int padWidth)

Causes the next added printer/parser to pad to a fixed width using a space. !(p) This padding will pad to a fixed width using spaces. !(p) During formatting, the decorated element will be output and then padded to the specified width. An exception will be thrown during formatting if the pad width is exceeded. !(p) During parsing, the padding and decorated element are parsed. If parsing is lenient, then the pad width is treated as a maximum. The padding is parsed greedily. Thus, if the decorated element starts with the pad character, it will not be parsed.

padNext
DateTimeFormatterBuilder padNext(int padWidth, char padChar)

Causes the next added printer/parser to pad to a fixed width. !(p) This padding is intended for padding other than zero-padding. Zero-padding should be achieved using the appendValue methods. !(p) During formatting, the decorated element will be output and then padded to the specified width. An exception will be thrown during formatting if the pad width is exceeded. !(p) During parsing, the padding and decorated element are parsed. If parsing is lenient, then the pad width is treated as a maximum. If parsing is case insensitive, then the pad character is matched ignoring case. The padding is parsed greedily. Thus, if the decorated element starts with the pad character, it will not be parsed.

parseCaseInsensitive
DateTimeFormatterBuilder parseCaseInsensitive()

Changes the parse style to be case insensitive for the remainder of the formatter. !(p) Parsing can be case sensitive or insensitive - by default it is case sensitive. This method allows the case sensitivity setting of parsing to be changed. !(p) Calling this method changes the state of the builder such that all subsequent builder method calls will parse text _in case insensitive mode. See {@link #parseCaseSensitive()} for the opposite setting. The parse case sensitive/insensitive methods may be called at any point _in the builder, thus the parser can swap between case parsing modes multiple times during the parse.

parseCaseSensitive
DateTimeFormatterBuilder parseCaseSensitive()

Changes the parse style to be case sensitive for the remainder of the formatter. !(p) Parsing can be case sensitive or insensitive - by default it is case sensitive. This method allows the case sensitivity setting of parsing to be changed. !(p) Calling this method changes the state of the builder such that all subsequent builder method calls will parse text _in case sensitive mode. See {@link #parseCaseInsensitive} for the opposite setting. The parse case sensitive/insensitive methods may be called at any point _in the builder, thus the parser can swap between case parsing modes multiple times during the parse. !(p) Since the default is case sensitive, this method should only be used after a previous call to {@code #parseCaseInsensitive}.

parseDefaulting
DateTimeFormatterBuilder parseDefaulting(TemporalField field, long value)

Appends a default value for a field to the formatter for use _in parsing. !(p) This appends an instruction to the builder to inject a default value into the parsed result. This is especially useful _in conjunction with optional parts of the formatter. !(p) For example, consider a formatter that parses the year, followed by an optional month, with a further optional day-of-month. Using such a formatter would require the calling code to check whether a full date, year-month or just a year had been parsed. This method can be used to default the month and day-of-month to a sensible value, such as the first of the month, allowing the calling code to always get a date. !(p) During formatting, this method has no effect. !(p) During parsing, the current state of the parse is inspected. If the specified field has no associated value, because it has not been parsed successfully at that point, then the specified value is injected into the parse result. Injection is immediate, thus the field-value pair will be visible to any subsequent elements _in the formatter. As such, this method is normally called at the end of the builder.

parseLenient
DateTimeFormatterBuilder parseLenient()

Changes the parse style to be lenient for the remainder of the formatter. Note that case sensitivity is set separately to this method. !(p) Parsing can be strict or lenient - by default its strict. This controls the degree of flexibility _in matching the text and sign styles. Applications calling this method should typically also call {@link #parseCaseInsensitive()}. !(p) When used, this method changes the parsing to be lenient from this point onwards. The change will remain _in force until the end of the formatter that is eventually constructed or until {@code parseStrict} is called.

parseStrict
DateTimeFormatterBuilder parseStrict()

Changes the parse style to be strict for the remainder of the formatter. !(p) Parsing can be strict or lenient - by default its strict. This controls the degree of flexibility _in matching the text and sign styles. !(p) When used, this method changes the parsing to be strict from this point onwards. As strict is the default, this is normally only needed after calling {@link #parseLenient()}. The change will remain _in force until the end of the formatter that is eventually constructed or until {@code parseLenient} is called.

toFormatter
DateTimeFormatter toFormatter()

Completes this builder by creating the {@code DateTimeFormatter} using the default locale. !(p) This will create a formatter with the {@linkplain Locale#getDefault(Locale.Category) default FORMAT locale}. Numbers will be printed and parsed using the standard DecimalStyle. The resolver style will be {@link ResolverStyle#SMART SMART}. !(p) Calling this method will end any open optional sections by repeatedly calling {@link #optionalEnd()} before creating the formatter. !(p) This builder can still be used after creating the formatter if desired, although the state may have been changed by calls to {@code optionalEnd}.

toFormatter
DateTimeFormatter toFormatter(Locale locale)

Completes this builder by creating the {@code DateTimeFormatter} using the specified locale. !(p) This will create a formatter with the specified locale. Numbers will be printed and parsed using the standard DecimalStyle. The resolver style will be {@link ResolverStyle#SMART SMART}. !(p) Calling this method will end any open optional sections by repeatedly calling {@link #optionalEnd()} before creating the formatter. !(p) This builder can still be used after creating the formatter if desired, although the state may have been changed by calls to {@code optionalEnd}.

toFormatter
DateTimeFormatter toFormatter(ResolverStyle resolverStyle, Chronology chrono)

Completes this builder by creating the formatter. This uses the default locale.

Static functions

BASIC_ISO_DATE
DateTimeFormatter BASIC_ISO_DATE()

The ISO date formatter that formats or parses a date without an offset, such as '20111203'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 basic local date format. The format consists of: !(ul) !(li)Four digits for the {@link ChronoField#YEAR year}. Only years _in the range 0000 to 9999 are supported. !(li)Two digits for the {@link ChronoField#MONTH_OF_YEAR month-of-year}. This is pre-padded by zero to ensure two digits. !(li)Two digits for the {@link ChronoField#DAY_OF_MONTH day-of-month}. This is pre-padded by zero to ensure two digits. !(li)If the offset is not available to format or parse then the format is complete. !(li)The {@link ZoneOffset#getId() offset ID} without colons. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. The offset parsing is lenient, which allows the minutes and seconds to be optional. Parsing is case insensitive. </ul> !(p) As this formatter has an optional element, it may be necessary to parse using {@link DateTimeFormatter#parseBest}. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_DATE
DateTimeFormatter ISO_DATE()

The ISO date formatter that formats or parses a date with the offset if available, such as '2011-12-03' or '2011-12-03+01:00'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended date format. The format consists of: !(ul) !(li)The {@link #ISO_LOCAL_DATE} !(li)If the offset is not available then the format is complete. !(li)The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. Parsing is case insensitive. </ul> !(p) As this formatter has an optional element, it may be necessary to parse using {@link DateTimeFormatter#parseBest}. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_DATE_TIME
DateTimeFormatter ISO_DATE_TIME()

The ISO-like date-time formatter that formats or parses a date-time with the offset and zone if available, such as '2011-12-03T10:15:30', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended local or offset date-time format, as well as the extended non-ISO form specifying the time-zone. The format consists of: !(ul) !(li)The {@link #ISO_LOCAL_DATE_TIME} !(li)If the offset is not available to format or parse then the format is complete. !(li)The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. !(li)If the zone ID is not available or is a {@code ZoneOffset} then the format is complete. !(li)An open square bracket '['. !(li)The {@link ZoneId#getId() zone ID}. This is not part of the ISO-8601 standard. Parsing is case sensitive. !(li)A close square bracket ']'. </ul> !(p) As this formatter has an optional element, it may be necessary to parse using {@link DateTimeFormatter#parseBest}. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_INSTANT
DateTimeFormatter ISO_INSTANT()

The ISO instant formatter that formats or parses an instant _in UTC, such as '2011-12-03T10:15:30Z'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 instant format. When formatting, the instant will always be suffixed by 'Z' to indicate UTC. The second-of-minute is always output. The nano-of-second outputs zero, three, six or nine digits as necessary. When parsing, the behaviour of {@link DateTimeFormatterBuilder#appendOffsetId()} will be used to parse the offset, converting the instant to UTC as necessary. The time to at least the seconds field is required. Fractional seconds from zero to nine are parsed. The localized decimal style is not used. !(p) This is a special case formatter intended to allow a human readable form of an {@link hunt.time.Instant}. The {@code Instant} class is designed to only represent a point _in time and internally stores a value _in nanoseconds from a fixed epoch of 1970-01-01Z. As such, an {@code Instant} cannot be formatted as a date or time without providing some form of time-zone. This formatter allows the {@code Instant} to be formatted, by providing a suitable conversion using {@code ZoneOffset.UTC}. !(p) The format consists of: !(ul) !(li)The {@link #ISO_OFFSET_DATE_TIME} where the instant is converted from {@link ChronoField#INSTANT_SECONDS} and {@link ChronoField#NANO_OF_SECOND} using the {@code UTC} offset. Parsing is case insensitive. </ul> !(p) The returned formatter has no override chronology or zone. It uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_LOCAL_DATE
DateTimeFormatter ISO_LOCAL_DATE()

The ISO date formatter that formats or parses a date without an offset, such as '2011-12-03'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended local date format. The format consists of: !(ul) !(li)Four digits or more for the {@link ChronoField#YEAR year}. Years _in the range 0000 to 9999 will be pre-padded by zero to ensure four digits. Years outside that range will have a prefixed positive or negative symbol. !(li)A dash !(li)Two digits for the {@link ChronoField#MONTH_OF_YEAR month-of-year}. This is pre-padded by zero to ensure two digits. !(li)A dash !(li)Two digits for the {@link ChronoField#DAY_OF_MONTH day-of-month}. This is pre-padded by zero to ensure two digits. </ul> !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_LOCAL_DATE_TIME
DateTimeFormatter ISO_LOCAL_DATE_TIME()

The ISO date-time formatter that formats or parses a date-time without an offset, such as '2011-12-03T10:15:30'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset date-time format. The format consists of: !(ul) !(li)The {@link #ISO_LOCAL_DATE} !(li)The letter 'T'. Parsing is case insensitive. !(li)The {@link #ISO_LOCAL_TIME} </ul> !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_LOCAL_TIME
DateTimeFormatter ISO_LOCAL_TIME()

The ISO time formatter that formats or parses a time without an offset, such as '10:15' or '10:15:30'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended local time format. The format consists of: !(ul) !(li)Two digits for the {@link ChronoField#HOUR_OF_DAY hour-of-day}. This is pre-padded by zero to ensure two digits. !(li)A colon !(li)Two digits for the {@link ChronoField#MINUTE_OF_HOUR minute-of-hour}. This is pre-padded by zero to ensure two digits. !(li)If the second-of-minute is not available then the format is complete. !(li)A colon !(li)Two digits for the {@link ChronoField#SECOND_OF_MINUTE second-of-minute}. This is pre-padded by zero to ensure two digits. !(li)If the nano-of-second is zero or not available then the format is complete. !(li)A decimal point !(li)One to nine digits for the {@link ChronoField#NANO_OF_SECOND nano-of-second}. As many digits will be output as required. </ul> !(p) The returned formatter has no override chronology or zone. It uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_OFFSET_DATE
DateTimeFormatter ISO_OFFSET_DATE()

The ISO date formatter that formats or parses a date with an offset, such as '2011-12-03+01:00'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset date format. The format consists of: !(ul) !(li)The {@link #ISO_LOCAL_DATE} !(li)The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. Parsing is case insensitive. </ul> !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_OFFSET_DATE_TIME
DateTimeFormatter ISO_OFFSET_DATE_TIME()

The ISO date-time formatter that formats or parses a date-time with an offset, such as '2011-12-03T10:15:30+01:00'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset date-time format. The format consists of: !(ul) !(li)The {@link #ISO_LOCAL_DATE_TIME} !(li)The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. The offset parsing is lenient, which allows the minutes and seconds to be optional. Parsing is case insensitive. </ul> !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_OFFSET_TIME
DateTimeFormatter ISO_OFFSET_TIME()

The ISO time formatter that formats or parses a time with an offset, such as '10:15+01:00' or '10:15:30+01:00'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset time format. The format consists of: !(ul) !(li)The {@link #ISO_LOCAL_TIME} !(li)The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. Parsing is case insensitive. </ul> !(p) The returned formatter has no override chronology or zone. It uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_ORDINAL_DATE
DateTimeFormatter ISO_ORDINAL_DATE()

The ISO date formatter that formats or parses the ordinal date without an offset, such as '2012-337'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended ordinal date format. The format consists of: !(ul) !(li)Four digits or more for the {@link ChronoField#YEAR year}. Years _in the range 0000 to 9999 will be pre-padded by zero to ensure four digits. Years outside that range will have a prefixed positive or negative symbol. !(li)A dash !(li)Three digits for the {@link ChronoField#DAY_OF_YEAR day-of-year}. This is pre-padded by zero to ensure three digits. !(li)If the offset is not available to format or parse then the format is complete. !(li)The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. Parsing is case insensitive. </ul> !(p) As this formatter has an optional element, it may be necessary to parse using {@link DateTimeFormatter#parseBest}. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_TIME
DateTimeFormatter ISO_TIME()

The ISO time formatter that formats or parses a time, with the offset if available, such as '10:15', '10:15:30' or '10:15:30+01:00'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset time format. The format consists of: !(ul) !(li)The {@link #ISO_LOCAL_TIME} !(li)If the offset is not available then the format is complete. !(li)The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. Parsing is case insensitive. </ul> !(p) As this formatter has an optional element, it may be necessary to parse using {@link DateTimeFormatter#parseBest}. !(p) The returned formatter has no override chronology or zone. It uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_WEEK_DATE
DateTimeFormatter ISO_WEEK_DATE()

The ISO date formatter that formats or parses the week-based date without an offset, such as '2012-W48-6'. !(p) This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended week-based date format. The format consists of: !(ul) !(li)Four digits or more for the {@link IsoFields#WEEK_BASED_YEAR week-based-year}. Years _in the range 0000 to 9999 will be pre-padded by zero to ensure four digits. Years outside that range will have a prefixed positive or negative symbol. !(li)A dash !(li)The letter 'W'. Parsing is case insensitive. !(li)Two digits for the {@link IsoFields#WEEK_OF_WEEK_BASED_YEAR week-of-week-based-year}. This is pre-padded by zero to ensure three digits. !(li)A dash !(li)One digit for the {@link ChronoField#DAY_OF_WEEK day-of-week}. The value run from Monday (1) to Sunday (7). !(li)If the offset is not available to format or parse then the format is complete. !(li)The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then they will be handled even though this is not part of the ISO-8601 standard. Parsing is case insensitive. </ul> !(p) As this formatter has an optional element, it may be necessary to parse using {@link DateTimeFormatter#parseBest}. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

ISO_ZONED_DATE_TIME
DateTimeFormatter ISO_ZONED_DATE_TIME()

The ISO-like date-time formatter that formats or parses a date-time with offset and zone, such as '2011-12-03T10:15:30+01:00[Europe/Paris]'. !(p) This returns an immutable formatter capable of formatting and parsing a format that extends the ISO-8601 extended offset date-time format to add the time-zone. The section _in square brackets is not part of the ISO-8601 standard. The format consists of: !(ul) !(li)The {@link #ISO_OFFSET_DATE_TIME} !(li)If the zone ID is not available or is a {@code ZoneOffset} then the format is complete. !(li)An open square bracket '['. !(li)The {@link ZoneId#getId() zone ID}. This is not part of the ISO-8601 standard. Parsing is case sensitive. !(li)A close square bracket ']'. </ul> !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style.

QUERY_REGION_ONLY
TemporalQuery!(ZoneId) QUERY_REGION_ONLY()

Query for a time-zone that is region-only.

RFC_1123_DATE_TIME
DateTimeFormatter RFC_1123_DATE_TIME()

The RFC-1123 date-time formatter, such as 'Tue, 3 Jun 2008 11:05:30 GMT'. !(p) This returns an immutable formatter capable of formatting and parsing most of the RFC-1123 format. RFC-1123 updates RFC-822 changing the year from two digits to four. This implementation requires a four digit year. This implementation also does not handle North American or military zone names, only 'GMT' and offset amounts. !(p) The format consists of: !(ul) !(li)If the day-of-week is not available to format or parse then jump to day-of-month. !(li)Three letter {@link ChronoField#DAY_OF_WEEK day-of-week} _in English. !(li)A comma !(li)A space !(li)One or two digits for the {@link ChronoField#DAY_OF_MONTH day-of-month}. !(li)A space !(li)Three letter {@link ChronoField#MONTH_OF_YEAR month-of-year} _in English. !(li)A space !(li)Four digits for the {@link ChronoField#YEAR year}. Only years _in the range 0000 to 9999 are supported. !(li)A space !(li)Two digits for the {@link ChronoField#HOUR_OF_DAY hour-of-day}. This is pre-padded by zero to ensure two digits. !(li)A colon !(li)Two digits for the {@link ChronoField#MINUTE_OF_HOUR minute-of-hour}. This is pre-padded by zero to ensure two digits. !(li)If the second-of-minute is not available then jump to the next space. !(li)A colon !(li)Two digits for the {@link ChronoField#SECOND_OF_MINUTE second-of-minute}. This is pre-padded by zero to ensure two digits. !(li)A space !(li)The {@link ZoneOffset#getId() offset ID} without colons or seconds. An offset of zero uses "GMT". North American zone names and military zone names are not handled. </ul> !(p) Parsing is case insensitive. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style.

getLocalizedDateTimePattern
string getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale)

Gets the formatting pattern for date and time styles for a locale and chronology. The locale and chronology are used to lookup the locale specific format for the requested dateStyle and/or timeStyle. !(p) If the locale contains the "rg" (region override) <a href="../../util/Locale.html#def_locale_extension">Unicode extensions</a>, the formatting pattern is overridden with the one appropriate for the region.

ofLocalizedDate
DateTimeFormatter ofLocalizedDate(FormatStyle dateStyle)

Returns a locale specific date format for the ISO chronology. !(p) This returns a formatter that will format or parse a date. The exact format pattern used varies by locale. !(p) The locale is determined from the formatter. The formatter returned directly by this method will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. The locale can be controlled using {@link DateTimeFormatter#withLocale(Locale) withLocale(Locale)} on the result of this method. !(p) Note that the localized pattern is looked up lazily. This {@code DateTimeFormatter} holds the style required and the locale, looking up the pattern required on demand. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style.

ofLocalizedDateTime
DateTimeFormatter ofLocalizedDateTime(FormatStyle dateTimeStyle)

Returns a locale specific date-time formatter for the ISO chronology. !(p) This returns a formatter that will format or parse a date-time. The exact format pattern used varies by locale. !(p) The locale is determined from the formatter. The formatter returned directly by this method will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. The locale can be controlled using {@link DateTimeFormatter#withLocale(Locale) withLocale(Locale)} on the result of this method. !(p) Note that the localized pattern is looked up lazily. This {@code DateTimeFormatter} holds the style required and the locale, looking up the pattern required on demand. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. The {@code FULL} and {@code LONG} styles typically require a time-zone. When formatting using these styles, a {@code ZoneId} must be available, either by using {@code ZonedDateTime} or {@link DateTimeFormatter#withZone}.

ofLocalizedDateTime
DateTimeFormatter ofLocalizedDateTime(FormatStyle dateStyle, FormatStyle timeStyle)

Returns a locale specific date and time format for the ISO chronology. !(p) This returns a formatter that will format or parse a date-time. The exact format pattern used varies by locale. !(p) The locale is determined from the formatter. The formatter returned directly by this method will use the {@link Locale#getDefault() default FORMAT locale}. The locale can be controlled using {@link DateTimeFormatter#withLocale(Locale) withLocale(Locale)} on the result of this method. !(p) Note that the localized pattern is looked up lazily. This {@code DateTimeFormatter} holds the style required and the locale, looking up the pattern required on demand. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. The {@code FULL} and {@code LONG} styles typically require a time-zone. When formatting using these styles, a {@code ZoneId} must be available, either by using {@code ZonedDateTime} or {@link DateTimeFormatter#withZone}.

ofLocalizedTime
DateTimeFormatter ofLocalizedTime(FormatStyle timeStyle)

Returns a locale specific time format for the ISO chronology. !(p) This returns a formatter that will format or parse a time. The exact format pattern used varies by locale. !(p) The locale is determined from the formatter. The formatter returned directly by this method will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. The locale can be controlled using {@link DateTimeFormatter#withLocale(Locale) withLocale(Locale)} on the result of this method. !(p) Note that the localized pattern is looked up lazily. This {@code DateTimeFormatter} holds the style required and the locale, looking up the pattern required on demand. !(p) The returned formatter has a chronology of ISO set to ensure dates _in other calendar systems are correctly converted. It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. The {@code FULL} and {@code LONG} styles typically require a time-zone. When formatting using these styles, a {@code ZoneId} must be available, either by using {@code ZonedDateTime} or {@link DateTimeFormatter#withZone}.

ofPattern
DateTimeFormatter ofPattern(string pattern)

Creates a formatter using the specified pattern. !(p) This method will create a formatter based on a simple <a href="#patterns">pattern of letters and symbols</a> as described _in the class documentation. For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'. !(p) The formatter will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter. Alternatively use the {@link #ofPattern(string, Locale)} variant of this method. !(p) The returned formatter has no override chronology or zone. It uses {@link ResolverStyle#SMART SMART} resolver style.

ofPattern
DateTimeFormatter ofPattern(string pattern, Locale locale)

Creates a formatter using the specified pattern and locale. !(p) This method will create a formatter based on a simple <a href="#patterns">pattern of letters and symbols</a> as described _in the class documentation. For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'. !(p) The formatter will use the specified locale. This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter. !(p) The returned formatter has no override chronology or zone. It uses {@link ResolverStyle#SMART SMART} resolver style.

Static variables

LENGTH_SORT
Comparator!(string) LENGTH_SORT;

Map of letters to fields.

Meta