Module java.base

Class DateTimeFormatterBuilder

java.lang.Object
java.time.format.DateTimeFormatterBuilder

public final class DateTimeFormatterBuilder extends Object
Builder to create date-time formatters.

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:

  • Value - a numeric value
  • Fraction - a fractional value including the decimal place. Always use this when outputting fractions to ensure that the fraction is parsed correctly
  • Text - the textual equivalent for the value
  • OffsetId/Offset - the zone offset
  • ZoneId - the time-zone id
  • ZoneText - the name of the time-zone
  • ChronologyId - the chronology id
  • ChronologyText - the name of the chronology
  • Literal - a text literal
  • Nested and Optional - formats can be nested or made optional
In addition, any of the elements may be decorated by padding, either with spaces or any other character.

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 Requirements:
This class is a mutable builder intended for use from a single thread.
Since:
1.8