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 java.lang.Object implements DateTimeFormatterBuilder.DateTimePrinterParser
Prints and parses a numeric date-time field with optional padding.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int[]EXCEED_POINTSArray of 10 to the power of n.(package private) TemporalFieldfield(package private) intmaxWidth(package private) intminWidth(package private) SignStylesignStyle(package private) intsubsequentWidth
-
Constructor Summary
Constructors Modifier Constructor Description (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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) longgetValue(DateTimePrintContext context, long value)Gets the value to output.(package private) booleanisFixedWidth(DateTimeParseContext context)intparse(DateTimeParseContext context, java.lang.CharSequence text, int position)Parses text into date-time information.booleanprint(DateTimePrintContext context, java.lang.StringBuilder buf)Prints the date-time object to the buffer.(package private) intsetValue(DateTimeParseContext context, long value, int errorPos, int successPos)Stores the value.java.lang.StringtoString()(package private) DateTimeFormatterBuilder.NumberPrinterParserwithFixedWidth()Returns a new instance with fixed width flag set.(package private) DateTimeFormatterBuilder.NumberPrinterParserwithSubsequentWidth(int subsequentWidth)Returns a new instance with an updated subsequent width.
-
-
-
Field Detail
-
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 Detail
-
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 Detail
-
withFixedWidth
DateTimeFormatterBuilder.NumberPrinterParser 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, java.lang.StringBuilder buf)
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
long getValue(DateTimePrintContext context, long value)
Gets the value to output.- Parameters:
context- the contextvalue- the value of the field, not null- Returns:
- the value
-
isFixedWidth
boolean isFixedWidth(DateTimeParseContext context)
-
parse
public int parse(DateTimeParseContext context, java.lang.CharSequence text, int position)
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
int setValue(DateTimeParseContext context, long value, int errorPos, int successPos)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-