Package org.threeten.bp.format
Class DateTimePrintContext
java.lang.Object
org.threeten.bp.format.DateTimePrintContext
Context object used during date and time printing.
This class provides a single wrapper to items used in the print.
Specification for implementors
This class is a mutable context intended for use from a single thread. Usage of the class is thread-safe within standard printing as the framework creates a new instance of the class for each print and printing is single-threaded.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LocaleThe locale, not null.private intWhether the current formatter is optional.private DecimalStyleThe symbols, not null.private TemporalAccessorThe temporal being output. -
Constructor Summary
ConstructorsConstructorDescriptionDateTimePrintContext(TemporalAccessor temporal, Locale locale, DecimalStyle symbols) DateTimePrintContext(TemporalAccessor temporal, DateTimeFormatter formatter) Creates a new instance of the context. -
Method Summary
Modifier and TypeMethodDescriptionprivate static TemporalAccessoradjust(TemporalAccessor temporal, DateTimeFormatter formatter) (package private) voidEnds the printing of an optional segment of the input.(package private) LocaleGets the locale.(package private) DecimalStyleGets the formatting symbols.(package private) TemporalAccessorGets the temporal object being output.(package private) LonggetValue(TemporalField field) Gets the value of the specified field.(package private) <R> RgetValue(TemporalQuery<R> query) Gets a value using a query.(package private) voidsetDateTime(TemporalAccessor temporal) Sets the date-time being output.(package private) voidSets the locale.(package private) voidStarts the printing of an optional segment of the input.toString()Returns a string version of the context for debugging.
-
Field Details
-
temporal
The temporal being output. -
locale
The locale, not null. -
symbols
The symbols, not null. -
optional
private int optionalWhether the current formatter is optional.
-
-
Constructor Details
-
DateTimePrintContext
DateTimePrintContext(TemporalAccessor temporal, DateTimeFormatter formatter) Creates a new instance of the context.- Parameters:
temporal- the temporal object being output, not nullformatter- the formatter controlling the print, not null
-
DateTimePrintContext
DateTimePrintContext(TemporalAccessor temporal, Locale locale, DecimalStyle symbols)
-
-
Method Details
-
adjust
-
getTemporal
TemporalAccessor getTemporal()Gets the temporal object being output.- Returns:
- the temporal object, not null
-
getLocale
Locale getLocale()Gets the locale.This locale is used to control localization in the print output except where localization is controlled by the symbols.
- Returns:
- the locale, not null
-
getSymbols
DecimalStyle getSymbols()Gets the formatting symbols.The symbols control the localization of numeric output.
- Returns:
- the formatting symbols, not null
-
startOptional
void startOptional()Starts the printing of an optional segment of the input. -
endOptional
void endOptional()Ends the printing of an optional segment of the input. -
getValue
Gets a value using a query.- Parameters:
query- the query to use, not null- Returns:
- the result, null if not found and optional is true
- Throws:
DateTimeException- if the type is not available and the section is not optional
-
getValue
Gets the value of the specified field.This will return the value for the specified field.
- Parameters:
field- the field to find, not null- Returns:
- the value, null if not found and optional is true
- Throws:
DateTimeException- if the field is not available and the section is not optional
-
toString
Returns a string version of the context for debugging. -
setDateTime
Sets the date-time being output.- Parameters:
temporal- the date-time object, not null
-
setLocale
Sets the locale.This locale is used to control localization in the print output except where localization is controlled by the symbols.
- Parameters:
locale- the locale, not null
-