spring-framework / org.springframework.format.datetime.standard / DateTimeContext

DateTimeContext

open class DateTimeContext

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 indicate the user has not specified a setting.

Author
Juergen Hoeller

Since
4.0

See Also
DateTimeContextHolder

Constructors

<init>

DateTimeContext()

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 indicate the user has not specified a setting.

Functions

getChronology

open fun getChronology(): Chronology

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

getFormatter

open fun getFormatter(formatter: DateTimeFormatter): DateTimeFormatter

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

getTimeZone

open fun getTimeZone(): ZoneId

Return the user's time zone, if any.

setChronology

open fun setChronology(chronology: Chronology): Unit

Set the user's chronology (calendar system).

setTimeZone

open fun setTimeZone(timeZone: ZoneId): Unit

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.