Class DateTimeContext
- java.lang.Object
 - org.springframework.format.datetime.standard.DateTimeContext
 
@UsesJava8 public class DateTimeContext extends Object
A context that holds user-specificjava.time(JSR-310) settings such as the user's Chronology (calendar system) and time zone. Anullproperty value indicate the user has not specified a setting.- Since:
 - 4.0
 - Author:
 - Juergen Hoeller
 - See Also:
 DateTimeContextHolder
Constructor Summary
Constructors Constructor Description DateTimeContext()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChronologygetChronology()Return the user's chronology (calendar system), if any.DateTimeFormattergetFormatter(DateTimeFormatter formatter)Get the DateTimeFormatter with the this context's settings applied to the baseformatter.ZoneIdgetTimeZone()Return the user's time zone, if any.voidsetChronology(Chronology chronology)Set the user's chronology (calendar system).voidsetTimeZone(ZoneId timeZone)Set the user's time zone.
Constructor Detail
DateTimeContext
public DateTimeContext()
Method Detail
setChronology
public void setChronology(Chronology chronology)
Set the user's chronology (calendar system).
getChronology
public Chronology getChronology()
Return the user's chronology (calendar system), if any.
setTimeZone
public void setTimeZone(ZoneId timeZone)
Set the user's time zone.Alternatively, set a
TimeZoneAwareLocaleContextonLocaleContextHolder. This context class will fall back to checking the locale context if no setting has been provided here.
getTimeZone
public ZoneId getTimeZone()
Return the user's time zone, if any.
getFormatter
public DateTimeFormatter getFormatter(DateTimeFormatter formatter)
Get the DateTimeFormatter with the this context's settings applied to the baseformatter.- Parameters:
 formatter- the base formatter that establishes default formatting rules, generally context-independent- Returns:
 - the contextual DateTimeFormatter