Top Description Fields Constructors Methods
org.springframework.format.datetime.standard

public Class DateTimeContext

extends Object
Class Inheritance
Imports
java.time.ZoneId, java.time.chrono.Chronology, java.time.format.DateTimeFormatter, java.util.TimeZone, org.springframework.context.i18n.LocaleContext, .LocaleContextHolder, .TimeZoneAwareLocaleContext, org.springframework.lang.Nullable

A context that holds user-specific java.time (JSR-310) settings such as the user's Chronology (calendar system) and time zone.

A null property value indicates the user has not specified a setting.

Author
Juergen Hoeller
Since
4.0
See Also
DateTimeContextHolder

Field Summary

Modifier and TypeField and Description
private Chronology
private ZoneId

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Chronology
getChronology()

Return the user's chronology (calendar system), if any.

public DateTimeFormatter

Returns:

the contextual DateTimeFormatter
getFormatter
(DateTimeFormatter
the base formatter that establishes default formatting rules, generally context-independent
formatter
)

Get the DateTimeFormatter with this context's settings applied to the base formatter.

public ZoneId
getTimeZone()

Return the user's time zone, if any.

public void
setChronology(Chronology chronology)

Set the user's chronology (calendar system).

public void
setTimeZone(ZoneId timeZone)

Set the user's time zone.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

chronologyback to summary
private Chronology chronology
Annotations
@Nullable
timeZoneback to summary
private ZoneId timeZone
Annotations
@Nullable

Constructor Detail

DateTimeContextback to summary
public DateTimeContext()

Method Detail

getChronologyback to summary
public Chronology getChronology()

Return the user's chronology (calendar system), if any.

Annotations
@Nullable
getFormatterback to summary
public DateTimeFormatter getFormatter(DateTimeFormatter formatter)

Get the DateTimeFormatter with this context's settings applied to the base formatter.

Parameters
formatter:DateTimeFormatter

the base formatter that establishes default formatting rules, generally context-independent

Returns:DateTimeFormatter

the contextual DateTimeFormatter

getTimeZoneback to summary
public ZoneId getTimeZone()

Return the user's time zone, if any.

Annotations
@Nullable
setChronologyback to summary
public void setChronology(Chronology chronology)

Set the user's chronology (calendar system).

setTimeZoneback to summary
public void setTimeZone(ZoneId timeZone)

Set the user's time zone.

Alternatively, set a TimeZoneAwareLocaleContext on LocaleContextHolder. This context class will fall back to checking the locale context if no setting has been provided here.

See Also
org.springframework.context.i18n.LocaleContextHolder#getTimeZone(), org.springframework.context.i18n.LocaleContextHolder#setLocaleContext