Package javax.time.calendar.format
Class FractionPrinterParser
- java.lang.Object
-
- javax.time.calendar.format.FractionPrinterParser
-
- All Implemented Interfaces:
DateTimeParser
,DateTimePrinter
final class FractionPrinterParser extends java.lang.Object implements DateTimePrinter, DateTimeParser
Prints and parses a numeric date-time field with optional padding.FractionPrinterParser is immutable and thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private int
maxWidth
The maximum width, from 0 to 9.private int
minWidth
The minimum width, from 0 to 9.private DateTimeFieldRule<?>
rule
The rule to output, not null.
-
Constructor Summary
Constructors Constructor Description FractionPrinterParser(DateTimeFieldRule<?> rule, int minWidth, int maxWidth)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isPrintDataAvailable(Calendrical calendrical)
Checks if the calendrical contains the data necessary to be printed.int
parse(DateTimeParseContext context, java.lang.String parseText, int position)
Parses from the supplied text and position into the calendrical.void
print(Calendrical calendrical, java.lang.Appendable appendable, DateTimeFormatSymbols symbols)
Prints the calendrical object to the appendable.java.lang.String
toString()
-
-
-
Field Detail
-
rule
private final DateTimeFieldRule<?> rule
The rule to output, not null.
-
minWidth
private final int minWidth
The minimum width, from 0 to 9.
-
maxWidth
private final int maxWidth
The maximum width, from 0 to 9.
-
-
Constructor Detail
-
FractionPrinterParser
FractionPrinterParser(DateTimeFieldRule<?> rule, int minWidth, int maxWidth)
Constructor.- Parameters:
rule
- the rule to output, not nullminWidth
- the minimum width to output, from 0 to 9maxWidth
- the maximum width to output, from 0 to 9
-
-
Method Detail
-
print
public void print(Calendrical calendrical, java.lang.Appendable appendable, DateTimeFormatSymbols symbols) throws java.io.IOException
Prints the calendrical object to the appendable.- Specified by:
print
in interfaceDateTimePrinter
- Parameters:
calendrical
- the calendrical to print, not nullappendable
- the appendable to add to, not nullsymbols
- the formatting symbols to use, not null- Throws:
java.io.IOException
- if the append throws an exception
-
isPrintDataAvailable
public boolean isPrintDataAvailable(Calendrical calendrical)
Checks if the calendrical contains the data necessary to be printed.The implementation should not check the validity of the data, just whether there is sufficient data to attempt a print.
- Specified by:
isPrintDataAvailable
in interfaceDateTimePrinter
- Parameters:
calendrical
- the calendrical to check, not null- Returns:
- true if the calendrical can be printed, false if not
-
parse
public int parse(DateTimeParseContext context, java.lang.String parseText, int position)
Parses from the supplied text and position into the calendrical.- Specified by:
parse
in interfaceDateTimeParser
- Parameters:
context
- the context to use and parse into, not nullparseText
- 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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-