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

public final Class DateTimeContextHolder

extends Object
Class Inheritance
Imports
java.time.format.DateTimeFormatter, java.util.Locale, org.springframework.core.NamedThreadLocal, org.springframework.lang.Nullable

A holder for a thread-local user DateTimeContext.
Author
Juergen Hoeller
Since
4.0
See Also
org.springframework.context.i18n.LocaleContextHolder

Field Summary

Modifier and TypeField and Description
private static final ThreadLocal<DateTimeContext>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static DateTimeContext

Returns:

the current DateTimeContext, or null if none
getDateTimeContext
()

Return the DateTimeContext associated with the current thread, if any.

public static DateTimeFormatter

Returns:

the user-specific DateTimeFormatter
getFormatter
(DateTimeFormatter
the base formatter that establishes default formatting rules (generally user independent)
formatter
,
Locale
the current user locale (may be null if not known)
locale
)

Obtain a DateTimeFormatter with user-specific settings applied to the given base formatter.

public static void
resetDateTimeContext()

Reset the DateTimeContext for the current thread.

public static void
setDateTimeContext(DateTimeContext
the current DateTimeContext, or null to reset the thread-bound context
dateTimeContext
)

Associate the given DateTimeContext with the current thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dateTimeContextHolderback to summary
private static final ThreadLocal<DateTimeContext> dateTimeContextHolder

Constructor Detail

DateTimeContextHolderback to summary
private DateTimeContextHolder()

Method Detail

getDateTimeContextback to summary
public static DateTimeContext getDateTimeContext()

Return the DateTimeContext associated with the current thread, if any.

Returns:DateTimeContext

the current DateTimeContext, or null if none

Annotations
@Nullable
getFormatterback to summary
public static DateTimeFormatter getFormatter(DateTimeFormatter formatter, Locale locale)

Obtain a DateTimeFormatter with user-specific settings applied to the given base formatter.

Parameters
formatter:DateTimeFormatter

the base formatter that establishes default formatting rules (generally user independent)

locale:Locale

the current user locale (may be null if not known)

Returns:DateTimeFormatter

the user-specific DateTimeFormatter

resetDateTimeContextback to summary
public static void resetDateTimeContext()

Reset the DateTimeContext for the current thread.

setDateTimeContextback to summary
public static void setDateTimeContext(DateTimeContext dateTimeContext)

Associate the given DateTimeContext with the current thread.

Parameters
dateTimeContext:DateTimeContext

the current DateTimeContext, or null to reset the thread-bound context