Class JodaTimeContextHolder
- java.lang.Object
- org.springframework.format.datetime.joda.JodaTimeContextHolder
public final class JodaTimeContextHolder extends Object
A holder for a thread-localJodaTimeContextwith user-specific Joda-Time settings.- Since:
- 3.0
- Author:
- Keith Donald, Juergen Hoeller
- See Also:
LocaleContextHolder
Constructor Summary
Constructors Constructor Description JodaTimeContextHolder()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DateTimeFormattergetFormatter(DateTimeFormatter formatter, Locale locale)Obtain a DateTimeFormatter with user-specific settings applied to the given base Formatter.static JodaTimeContextgetJodaTimeContext()Return the JodaTimeContext associated with the current thread, if any.static voidresetJodaTimeContext()Reset the JodaTimeContext for the current thread.static voidsetJodaTimeContext(JodaTimeContext jodaTimeContext)Associate the given JodaTimeContext with the current thread.
Constructor Detail
JodaTimeContextHolder
public JodaTimeContextHolder()
Method Detail
resetJodaTimeContext
public static void resetJodaTimeContext()
Reset the JodaTimeContext for the current thread.
setJodaTimeContext
public static void setJodaTimeContext(JodaTimeContext jodaTimeContext)
Associate the given JodaTimeContext with the current thread.- Parameters:
jodaTimeContext- the current JodaTimeContext, ornullto reset the thread-bound context
getJodaTimeContext
public static JodaTimeContext getJodaTimeContext()
Return the JodaTimeContext associated with the current thread, if any.- Returns:
- the current JodaTimeContext, or
nullif none
getFormatter
public static DateTimeFormatter getFormatter(DateTimeFormatter formatter, 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