Package org.threeten.bp.format
Class DateTimePrintContext
- java.lang.Object
-
- org.threeten.bp.format.DateTimePrintContext
-
final class DateTimePrintContext extends java.lang.ObjectContext 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
Fields Modifier and Type Field Description private java.util.LocalelocaleThe locale, not null.private intoptionalWhether the current formatter is optional.private DecimalStylesymbolsThe symbols, not null.private TemporalAccessortemporalThe temporal being output.
-
Constructor Summary
Constructors Constructor Description DateTimePrintContext(TemporalAccessor temporal, java.util.Locale locale, DecimalStyle symbols)DateTimePrintContext(TemporalAccessor temporal, DateTimeFormatter formatter)Creates a new instance of the context.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static TemporalAccessoradjust(TemporalAccessor temporal, DateTimeFormatter formatter)(package private) voidendOptional()Ends the printing of an optional segment of the input.(package private) java.util.LocalegetLocale()Gets the locale.(package private) DecimalStylegetSymbols()Gets the formatting symbols.(package private) TemporalAccessorgetTemporal()Gets the temporal object being output.(package private) java.lang.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) voidsetLocale(java.util.Locale locale)Sets the locale.(package private) voidstartOptional()Starts the printing of an optional segment of the input.java.lang.StringtoString()Returns a string version of the context for debugging.
-
-
-
Field Detail
-
temporal
private TemporalAccessor temporal
The temporal being output.
-
locale
private java.util.Locale locale
The locale, not null.
-
symbols
private DecimalStyle symbols
The symbols, not null.
-
optional
private int optional
Whether the current formatter is optional.
-
-
Constructor Detail
-
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, java.util.Locale locale, DecimalStyle symbols)
-
-
Method Detail
-
adjust
private static TemporalAccessor adjust(TemporalAccessor temporal, DateTimeFormatter formatter)
-
getTemporal
TemporalAccessor getTemporal()
Gets the temporal object being output.- Returns:
- the temporal object, not null
-
getLocale
java.util.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
<R> R getValue(TemporalQuery<R> query)
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
java.lang.Long getValue(TemporalField field)
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
public java.lang.String toString()
Returns a string version of the context for debugging.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the context, not null
-
setDateTime
void setDateTime(TemporalAccessor temporal)
Sets the date-time being output.- Parameters:
temporal- the date-time object, not null
-
setLocale
void setLocale(java.util.Locale locale)
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
-
-