Package org.threeten.bp.format
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 Summary
FieldsModifier and TypeFieldDescription(package private) static final int[]Array of 10 to the power of n.(package private) final TemporalField(package private) final int(package private) final int(package private) final SignStyle(package private) final int -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)NumberPrinterParser(TemporalField field, int minWidth, int maxWidth, SignStyle signStyle) Constructor.privateNumberPrinterParser(TemporalField field, int minWidth, int maxWidth, SignStyle signStyle, int subsequentWidth) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) longgetValue(DateTimePrintContext context, long value) Gets the value to output.(package private) booleanisFixedWidth(DateTimeParseContext context) intparse(DateTimeParseContext context, CharSequence text, int position) Parses text into date-time information.booleanprint(DateTimePrintContext context, StringBuilder buf) Prints the date-time object to the buffer.(package private) intsetValue(DateTimeParseContext context, long value, int errorPos, int successPos) Stores the value.toString()(package private) DateTimeFormatterBuilder.NumberPrinterParserReturns a new instance with fixed width flag set.(package private) DateTimeFormatterBuilder.NumberPrinterParserwithSubsequentWidth(int subsequentWidth) Returns a new instance with an updated subsequent width.
-
Field Details
-
EXCEED_POINTS
static final int[] EXCEED_POINTSArray of 10 to the power of n. -
field
-
minWidth
final int minWidth -
maxWidth
final int maxWidth -
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 nullminWidth- the minimum field width, from 1 to 19maxWidth- the maximum field width, from minWidth to 19signStyle- 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 nullminWidth- the minimum field width, from 1 to 19maxWidth- the maximum field width, from minWidth to 19signStyle- the positive/negative sign style, not nullsubsequentWidth- the width of subsequent non-negative numbers, 0 or greater, -1 if fixed width due to active adjacent parsing
-
-
Method Details
-
withFixedWidth
DateTimeFormatterBuilder.NumberPrinterParser withFixedWidth()Returns a new instance with fixed width flag set.- Returns:
- a new updated printer-parser, not null
-
withSubsequentWidth
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
Description copied from interface:DateTimeFormatterBuilder.DateTimePrinterParserPrints 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:
printin interfaceDateTimeFormatterBuilder.DateTimePrinterParser- Parameters:
context- the context to print using, not nullbuf- the buffer to append to, not null- Returns:
- false if unable to query the value from the date-time, true otherwise
-
getValue
Gets the value to output.- Parameters:
context- the contextvalue- the value of the field, not null- Returns:
- the value
-
isFixedWidth
-
parse
Description copied from interface:DateTimeFormatterBuilder.DateTimePrinterParserParses 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:
parsein interfaceDateTimeFormatterBuilder.DateTimePrinterParser- Parameters:
context- the context to use and parse into, not nulltext- the input text to parse, not nullposition- 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
Stores the value.- Parameters:
context- the context to store into, not nullvalue- the valueerrorPos- the position of the field being parsedsuccessPos- the position after the field being parsed- Returns:
- the new position
-
toString
-