org.springframework.format.datetime.joda
Class JodaTimeContextHolder

java.lang.Object
  extended by org.springframework.format.datetime.joda.JodaTimeContextHolder

public final class JodaTimeContextHolder
extends Object

A holder for a thread-local user JodaTimeContext.

Since:
3.0
Author:
Keith Donald

Constructor Summary
JodaTimeContextHolder()
           
 
Method Summary
static org.joda.time.format.DateTimeFormatter getFormatter(org.joda.time.format.DateTimeFormatter formatter, Locale locale)
          Obtain a DateTimeFormatter with user-specific settings applied to the given base Formatter.
static JodaTimeContext getJodaTimeContext()
          Return the JodaTimeContext associated with the current thread, if any.
static void setJodaTimeContext(JodaTimeContext context)
          Associate the given JodaTimeContext with the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JodaTimeContextHolder

public JodaTimeContextHolder()
Method Detail

setJodaTimeContext

public static void setJodaTimeContext(JodaTimeContext context)
Associate the given JodaTimeContext with the current thread.

Parameters:
context - the current JodaTimeContext, or null to clear the thread-bound context

getJodaTimeContext

public static JodaTimeContext getJodaTimeContext()
Return the JodaTimeContext associated with the current thread, if any.

Returns:
the current JodaTimeContext, or null if none

getFormatter

public static org.joda.time.format.DateTimeFormatter getFormatter(org.joda.time.format.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 be null if not known)
Returns:
the user-specific DateTimeFormatter