Package javax.time.calendar.format
Class LocalizedPrinterParser
- java.lang.Object
-
- javax.time.calendar.format.LocalizedPrinterParser
-
- All Implemented Interfaces:
DateTimeParser,DateTimePrinter
final class LocalizedPrinterParser extends java.lang.Object implements DateTimePrinter, DateTimeParser
Prints or parses a localized pattern.LocalizedPrinterParser is immutable and thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private ChronologychronologyThe chronology to get the pattern for, may be null.private DateTimeFormatterBuilder.FormatStyledateStyleThe date style for the pattern, may be null.private DateTimeFormatterBuilder.FormatStyletimeStyleThe time style for the pattern, may be null.
-
Constructor Summary
Constructors Constructor Description LocalizedPrinterParser(DateTimeFormatterBuilder.FormatStyle dateStyle, DateTimeFormatterBuilder.FormatStyle timeStyle, Chronology chronology)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private DateTimeFormatterformatter(java.util.Locale locale)Gets the formatter to use.booleanisPrintDataAvailable(Calendrical calendrical)Checks if the calendrical contains the data necessary to be printed.intparse(DateTimeParseContext context, java.lang.String parseText, int position)Parses from the supplied text and position into the calendrical.voidprint(Calendrical calendrical, java.lang.Appendable appendable, DateTimeFormatSymbols symbols)Prints the calendrical object to the appendable.java.lang.StringtoString()
-
-
-
Field Detail
-
dateStyle
private final DateTimeFormatterBuilder.FormatStyle dateStyle
The date style for the pattern, may be null.
-
timeStyle
private final DateTimeFormatterBuilder.FormatStyle timeStyle
The time style for the pattern, may be null.
-
chronology
private final Chronology chronology
The chronology to get the pattern for, may be null.
-
-
Constructor Detail
-
LocalizedPrinterParser
LocalizedPrinterParser(DateTimeFormatterBuilder.FormatStyle dateStyle, DateTimeFormatterBuilder.FormatStyle timeStyle, Chronology chronology)
Constructor.- Parameters:
dateStyle- the date style to use, may be nulltimeStyle- the time style to use, may be nullchronology- the chronology to use, not null
-
-
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:
printin 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:
isPrintDataAvailablein 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:
parsein 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
-
formatter
private DateTimeFormatter formatter(java.util.Locale locale)
Gets the formatter to use.- Parameters:
locale- the locale to use, not null- Returns:
- the formatter, never null
- Throws:
java.lang.IllegalArgumentException- if the formatter cannot be found
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-