Class DateTimeFormatterBuilder.NumberPrinterParser

java.lang.Object
org.threeten.bp.format.DateTimeFormatterBuilder.NumberPrinterParser
All Implemented Interfaces:
DateTimeFormatterBuilder.DateTimePrinterParser
Direct Known Subclasses:
DateTimeFormatterBuilder.ReducedPrinterParser
Enclosing class:
DateTimeFormatterBuilder

static class DateTimeFormatterBuilder.NumberPrinterParser extends Object implements DateTimeFormatterBuilder.DateTimePrinterParser
Prints and parses a numeric date-time field with optional padding.
  • Field Details

    • EXCEED_POINTS

      static final int[] EXCEED_POINTS
      Array of 10 to the power of n.
    • field

      final TemporalField field
    • minWidth

      final int minWidth
    • maxWidth

      final int maxWidth
    • signStyle

      final SignStyle signStyle
    • subsequentWidth

      final int subsequentWidth
  • Constructor Details

    • NumberPrinterParser

      NumberPrinterParser(TemporalField field, int minWidth, int maxWidth, SignStyle signStyle)
      Constructor.
      Parameters:
      field - the field to print, not null
      minWidth - the minimum field width, from 1 to 19
      maxWidth - the maximum field width, from minWidth to 19
      signStyle - the positive/negative sign style, not null
    • NumberPrinterParser

      private NumberPrinterParser(TemporalField field, int minWidth, int maxWidth, SignStyle signStyle, int subsequentWidth)
      Constructor.
      Parameters:
      field - the field to print, not null
      minWidth - the minimum field width, from 1 to 19
      maxWidth - the maximum field width, from minWidth to 19
      signStyle - the positive/negative sign style, not null
      subsequentWidth - the width of subsequent non-negative numbers, 0 or greater, -1 if fixed width due to active adjacent parsing
  • Method Details

    • withFixedWidth

      Returns a new instance with fixed width flag set.
      Returns:
      a new updated printer-parser, not null
    • withSubsequentWidth

      DateTimeFormatterBuilder.NumberPrinterParser withSubsequentWidth(int subsequentWidth)
      Returns a new instance with an updated subsequent width.
      Parameters:
      subsequentWidth - the width of subsequent non-negative numbers, 0 or greater
      Returns:
      a new updated printer-parser, not null
    • print

      public boolean print(DateTimePrintContext context, StringBuilder buf)
      Description copied from interface: DateTimeFormatterBuilder.DateTimePrinterParser
      Prints the date-time object to the buffer.

      The context holds information to use during the print. It also contains the date-time information to be printed.

      The buffer must not be mutated beyond the content controlled by the implementation.

      Specified by:
      print in interface DateTimeFormatterBuilder.DateTimePrinterParser
      Parameters:
      context - the context to print using, not null
      buf - the buffer to append to, not null
      Returns:
      false if unable to query the value from the date-time, true otherwise
    • getValue

      long getValue(DateTimePrintContext context, long value)
      Gets the value to output.
      Parameters:
      context - the context
      value - the value of the field, not null
      Returns:
      the value
    • isFixedWidth

      boolean isFixedWidth(DateTimeParseContext context)
    • parse

      public int parse(DateTimeParseContext context, CharSequence text, int position)
      Description copied from interface: DateTimeFormatterBuilder.DateTimePrinterParser
      Parses text into date-time information.

      The context holds information to use during the parse. It is also used to store the parsed date-time information.

      Specified by:
      parse in interface DateTimeFormatterBuilder.DateTimePrinterParser
      Parameters:
      context - the context to use and parse into, not null
      text - the input text to parse, not null
      position - the position to start parsing at, from 0 to the text length
      Returns:
      the new parse position, where negative means an error with the error position encoded using the complement ~ operator
    • setValue

      int setValue(DateTimeParseContext context, long value, int errorPos, int successPos)
      Stores the value.
      Parameters:
      context - the context to store into, not null
      value - the value
      errorPos - the position of the field being parsed
      successPos - the position after the field being parsed
      Returns:
      the new position
    • toString

      public String toString()
      Overrides:
      toString in class Object