This allows a DateTimeFormatter
to be created.
All date-time formatters are created ultimately using this builder.
The basic elements of date-time can all be added:
Finally, a shorthand pattern, mostly compatible with java.text.SimpleDateFormat SimpleDateFormat
can be used, see appendPattern(String)
.
In practice, this simply parses the pattern and calls other methods on the builder.
Implementation Specification
This class is a mutable builder intended for use from a single thread.
Modifier and Type | Class and Description |
---|---|
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses a character literal. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses a chronology. |
pack-priv static class | DateTimeFormatterBuilder.
Composite printer and parser. |
pack-priv static interface | DateTimeFormatterBuilder.
Strategy for formatting/parsing date-time information. |
pack-priv static class | DateTimeFormatterBuilder.
DayPeriod class that represents a DayPeriod defined in CLDR. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses day periods. |
pack-priv static class | DateTimeFormatterBuilder.
Defaults a value into the parse if not currently present. |
pack-priv static class | DateTimeFormatterBuilder.
Prints and parses a numeric date-time field with optional padding. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses an ISO-8601 instant. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses an offset ID. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses a localized pattern. |
pack-priv static class | DateTimeFormatterBuilder.
Prints and parses a NANO_OF_SECOND field with optional padding. |
pack-priv static class | DateTimeFormatterBuilder.
Prints and parses a numeric date-time field with optional padding. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses an offset ID. |
pack-priv static class | DateTimeFormatterBuilder.
Pads the output to a fixed width. |
pack-priv static class | DateTimeFormatterBuilder.
A String based prefix tree for parsing time-zone names. |
pack-priv static class | DateTimeFormatterBuilder.
Prints and parses a reduced numeric date-time field. |
pack-priv static enum | DateTimeFormatterBuilder.
Enumeration to apply simple parse settings. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses a string literal. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses field text. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses a localized pattern from a localized field. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses a zone ID. |
pack-priv static class | DateTimeFormatterBuilder.
Prints or parses a zone ID. |
Modifier and Type | Field and Description |
---|---|
private DateTimeFormatterBuilder | active
The currently active builder, used by the outermost builder. |
private static final Map | FIELD_MAP
Map of letters to fields. |
private final boolean | optional
Whether this builder produces an optional formatter. |
private char | padNextChar
The character to pad the next field with. |
private int | padNextWidth
The width to pad the next field to. |
private final DateTimeFormatterBuilder | parent
The parent builder, null for the outermost builder. |
private final List | printerParsers
The list of printers that will be used. |
private static final TemporalQuery | QUERY_REGION_ONLY
Query for a time-zone that is region-only. |
private static final Pattern | |
private int | valueParserIndex
The index of the last variable width value parser. |
Access | Constructor and Description |
---|---|
public | |
private | DateTimeFormatterBuilder(DateTimeFormatterBuilder
the parent builder, not null parent, boolean whether the formatter is optional, not null optional)Constructs a new instance of the builder. |
Modifier and Type | Method and Description |
---|---|
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe formatter to add, not null formatter)Appends all the elements of a formatter to the builder. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullAppends the chronology ID, such as 'ISO' or 'ThaiBuddhist', to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe text style to use, not null textStyle)Appends the chronology name to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe text style to use, not null style)Appends the day period text to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field, int the minimum width of the field excluding the decimal point, from 0 to 9 minWidth, int the maximum width of the field excluding the decimal point, from 1 to 9 maxWidth, boolean whether to output the localized decimal point symbol decimalPoint)Appends the fractional value of a date-time field to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe text style to use, not null textStyle)Appends the generic time-zone name, such as 'Pacific Time', to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe text style to use, not null textStyle, Set<ZoneId> the set of preferred zone ids, not null preferredZones)Appends the generic time-zone name, such as 'Pacific Time', to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullAppends an instant using ISO-8601 to the formatter, formatting fractional digits in groups of three. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe number of fractional second digits to format with,
from 0 to 9, or -1 to use as many digits as necessary fractionalDigits)Appends an instant using ISO-8601 to the formatter with control over the number of fractional digits. |
private int | Returns: the index into the active parsers listthe printer-parser to add, not null ppAppends a printer and/or parser to the internal list handling padding. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe literal to append, not null literal)Appends a character literal to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe literal to append, not null literal)Appends a string literal to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe date style to use, null means no date required dateStyle, FormatStyle the time style to use, null means no time required timeStyle)Appends a localized date-time pattern to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe requested template to use, not null requestedTemplate)Appends a localized pattern to the formatter using the requested template. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe format style to use, not null style)Appends the localized zone offset, such as 'GMT+01:00', to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe pattern to use, not null pattern, String the text to use when the offset is zero, not null noOffsetText)Appends the zone offset, such as '+01:00', to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullAppends the zone offset, such as '+01:00', to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe formatter to add, not null formatter)Appends a formatter to the builder which will optionally format/parse. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe pattern to add, not null pattern)Appends the elements defined by the specified pattern to the builder. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field)Appends the text of a date-time field to the formatter using the full text style. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field, TextStyle the text style to use, not null textStyle)Appends the text of a date-time field to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field, Map<Long, String> the map from the value to the text textLookup)Appends the text of a date-time field to the formatter using the specified map to supply the text. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field)Appends the value of a date-time field to the formatter using a normal output style. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field, int the width of the printed field, from 1 to 19 width)Appends the value of a date-time field to the formatter using a fixed width, zero-padded approach. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field, int the minimum field width of the printed field, from 1 to 19 minWidth, int the maximum field width of the printed field, from 1 to 19 maxWidth, SignStyle the positive/negative output style, not null signStyle)Appends the value of a date-time field to the formatter providing full control over formatting. |
private DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe printer-parser, not null ppAppends a fixed or variable width printer-parser handling adjacent value mode. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field, int the field width of the printed and parsed field, from 1 to 10 width, int the maximum field width of the printed field, from 1 to 10 maxWidth, int the base value of the range of valid values baseValue)Appends the reduced value of a date-time field to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to append, not null field, int the field width of the printed and parsed field, from 1 to 10 width, int the maximum field width of the printed field, from 1 to 10 maxWidth, ChronoLocalDate the base date used to calculate the base value for the range
of valid values in the parsed chronology, not null baseDate)Appends the reduced value of a date-time field to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullAppends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullAppends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter, using the best available zone ID. This appends an instruction to format/parse the best available zone or offset ID to the builder. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullAppends the time-zone region ID, such as 'Europe/Paris', to the formatter,
rejecting the zone ID if it is a |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe text style to use, not null textStyle)Appends the time-zone name, such as 'British Summer Time', to the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe text style to use, not null textStyle, Set<ZoneId> the set of preferred zone ids, not null preferredZones)Appends the time-zone name, such as 'British Summer Time', to the formatter. |
private static int | Returns: the int style, or -1 if style is null, indicating un-requiredthe FormatStyle style style)Converts the given FormatStyle to the java.text.DateFormat style. |
public static String | Returns: the locale and Chronology specific formatting patternthe FormatStyle for the date, null for time-only pattern dateStyle, FormatStyle the FormatStyle for the time, null for date-only pattern timeStyle, Chronology the Chronology, non-null chrono, Locale the locale, non-null locale)Gets the formatting pattern for date and time styles for a locale and chronology. |
public static String | Returns: the locale and Chronology specific formatting patternthe requested template, not null requestedTemplate, Chronology the Chronology, non-null chrono, Locale the locale, non-null locale)Returns the formatting pattern for the requested template for a locale and chronology. |
public DateTimeFormatterBuilder | |
public DateTimeFormatterBuilder | |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe pad width, 1 or greater padWidth)Causes the next added printer/parser to pad to a fixed width using a space. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe pad width, 1 or greater padWidth, char the pad character padChar)Causes the next added printer/parser to pad to a fixed width. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullChanges the parse style to be case insensitive for the remainder of the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullChanges the parse style to be case sensitive for the remainder of the formatter. |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullthe field to default the value of, not null field, long the value to default the field to value)Appends a default value for a field to the formatter for use in parsing. |
private void | |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullChanges the parse style to be lenient for the remainder of the formatter. |
private void | |
public DateTimeFormatterBuilder | Returns: this, for chaining, not nullChanges the parse style to be strict for the remainder of the formatter. |
public DateTimeFormatter | Returns: the created formatter, not nullCompletes this builder by creating the |
public DateTimeFormatter | Returns: the created formatter, not nullthe locale to use for formatting, not null locale)Completes this builder by creating the |
pack-priv DateTimeFormatter | Returns: the created formatter, not nullthe resolver style to use, not null resolverStyle, Chronology chrono)Completes this builder by creating the formatter. |
private DateTimeFormatter | Returns: the created formatter, not nullthe locale to use for formatting, not null locale, ResolverStyle resolverStyle, Chronology the chronology to use, may be null chrono)Completes this builder by creating the formatter. |