类 DateTimeContextHolder
- java.lang.Object
- org.springframework.format.datetime.standard.DateTimeContextHolder
@UsesJava8 public final class DateTimeContextHolder extends Object
A holder for a thread-local userDateTimeContext
.- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller
- 另请参阅:
LocaleContextHolder
构造器概要
构造器 构造器 说明 DateTimeContextHolder()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static DateTimeContext
getDateTimeContext()
Return the DateTimeContext associated with the current thread, if any.static DateTimeFormatter
getFormatter(DateTimeFormatter formatter, Locale locale)
Obtain a DateTimeFormatter with user-specific settings applied to the given base Formatter.static void
resetDateTimeContext()
Reset the DateTimeContext for the current thread.static void
setDateTimeContext(DateTimeContext dateTimeContext)
Associate the given DateTimeContext with the current thread.
构造器详细资料
DateTimeContextHolder
public DateTimeContextHolder()
方法详细资料
resetDateTimeContext
public static void resetDateTimeContext()
Reset the DateTimeContext for the current thread.
setDateTimeContext
public static void setDateTimeContext(DateTimeContext dateTimeContext)
Associate the given DateTimeContext with the current thread.- 参数:
dateTimeContext
- the current DateTimeContext, ornull
to reset the thread-bound context
getDateTimeContext
public static DateTimeContext getDateTimeContext()
Return the DateTimeContext associated with the current thread, if any.- 返回:
- the current DateTimeContext, or
null
if none
getFormatter
public static DateTimeFormatter getFormatter(DateTimeFormatter formatter, Locale locale)
Obtain a DateTimeFormatter with user-specific settings applied to the given base Formatter.- 参数:
formatter
- the base formatter that establishes default formatting rules (generally user independent)locale
- the current user locale (may benull
if not known)- 返回:
- the user-specific DateTimeFormatter