Package javax.time.calendar.format
Class ZoneOffsetPrinterParser
java.lang.Object
javax.time.calendar.format.ZoneOffsetPrinterParser
- All Implemented Interfaces:
DateTimeParser
,DateTimePrinter
Prints or parses a zone offset.
ZoneOffsetPrinterParser is immutable and thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
Whether to allow seconds.private final boolean
Whether to include a colon.private final String
The text to use for UTC. -
Constructor Summary
ConstructorsConstructorDescriptionZoneOffsetPrinterParser
(String utcText, boolean includeColon, boolean allowSeconds) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isPrintDataAvailable
(Calendrical calendrical) Checks if the calendrical contains the data necessary to be printed.int
parse
(DateTimeParseContext context, String parseText, int position) Parses from the supplied text and position into the calendrical.private boolean
parseNumber
(int[] array, int arrayIndex, String parseText, boolean required) Parse a two digit zero-prefixed number.void
print
(Calendrical calendrical, Appendable appendable, DateTimeFormatSymbols symbols) Prints the calendrical object to the appendable.toString()
-
Field Details
-
utcText
The text to use for UTC. -
includeColon
private final boolean includeColonWhether to include a colon. -
allowSeconds
private final boolean allowSecondsWhether to allow seconds.
-
-
Constructor Details
-
ZoneOffsetPrinterParser
ZoneOffsetPrinterParser(String utcText, boolean includeColon, boolean allowSeconds) Constructor.- Parameters:
utcText
- the text to use for UTC, not nullincludeColon
- whether to include a colonallowSeconds
- whether to allow seconds
-
-
Method Details
-
print
public void print(Calendrical calendrical, Appendable appendable, DateTimeFormatSymbols symbols) throws 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:
IOException
- if the append throws an exception
-
isPrintDataAvailable
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
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
-
parseNumber
Parse a two digit zero-prefixed number.- Parameters:
array
- the array of parsed data, 0=pos,1=hours,2=mins,3=secs, not nullarrayIndex
- the index to parse the value intoparseText
- the offset id, not nullrequired
- whether this number is required- Returns:
- true if an error occurred
-
toString
-