Class DateTimeContextHolder
- java.lang.Object
- org.springframework.format.datetime.standard.DateTimeContextHolder
public final class DateTimeContextHolder extends Object
A holder for a thread-local userDateTimeContext.- Since:
- 4.0
- Author:
- Juergen Hoeller
- See Also:
LocaleContextHolder
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DateTimeContextgetDateTimeContext()Return the DateTimeContext associated with the current thread, if any.static DateTimeFormattergetFormatter(DateTimeFormatter formatter, Locale locale)Obtain a DateTimeFormatter with user-specific settings applied to the given base Formatter.static voidresetDateTimeContext()Reset the DateTimeContext for the current thread.static voidsetDateTimeContext(DateTimeContext dateTimeContext)Associate the given DateTimeContext with the current thread.
Method Detail
resetDateTimeContext
public static void resetDateTimeContext()
Reset the DateTimeContext for the current thread.
setDateTimeContext
public static void setDateTimeContext(@Nullable DateTimeContext dateTimeContext)
Associate the given DateTimeContext with the current thread.- Parameters:
dateTimeContext- the current DateTimeContext, ornullto reset the thread-bound context
getDateTimeContext
@Nullable public static DateTimeContext getDateTimeContext()
Return the DateTimeContext associated with the current thread, if any.- Returns:
- the current DateTimeContext, or
nullif none
getFormatter
public static DateTimeFormatter getFormatter(DateTimeFormatter formatter, @Nullable Locale locale)
Obtain a DateTimeFormatter with user-specific settings applied to the given base Formatter.- Parameters:
formatter- the base formatter that establishes default formatting rules (generally user independent)locale- the current user locale (may benullif not known)- Returns:
- the user-specific DateTimeFormatter