org.springframework.format.datetime.standard

Class DateTimeContext

  • java.lang.Object
    • org.springframework.format.datetime.standard.DateTimeContext


  • public class DateTimeContext
    extends java.lang.Object
    A context that holds user-specific java.time (JSR-310) settings such as the user's Chronology (calendar system) and time zone. A null property value indicate the user has not specified a setting.
    Since:
    4.0
    Author:
    Juergen Hoeller
    See Also:
    DateTimeContextHolder
    • Constructor Summary

      Constructors 
      Constructor and Description
      DateTimeContext() 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.time.chrono.Chronology getChronology()
      Return the user's chronology (calendar system), if any.
      java.time.format.DateTimeFormatter getFormatter(java.time.format.DateTimeFormatter formatter)
      Get the DateTimeFormatter with the this context's settings applied to the base formatter.
      java.time.ZoneId getTimeZone()
      Return the user's time zone, if any.
      void setChronology(java.time.chrono.Chronology chronology)
      Set the user's chronology (calendar system).
      void setTimeZone(java.time.ZoneId timeZone)
      Set the user's time zone.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DateTimeContext

        public DateTimeContext()
    • Method Detail

      • setChronology

        public void setChronology(@Nullable
                                  java.time.chrono.Chronology chronology)
        Set the user's chronology (calendar system).
      • getChronology

        @Nullable
        public java.time.chrono.Chronology getChronology()
        Return the user's chronology (calendar system), if any.
      • getTimeZone

        @Nullable
        public java.time.ZoneId getTimeZone()
        Return the user's time zone, if any.
      • getFormatter

        public java.time.format.DateTimeFormatter getFormatter(java.time.format.DateTimeFormatter formatter)
        Get the DateTimeFormatter with the this context's settings applied to the base formatter.
        Parameters:
        formatter - the base formatter that establishes default formatting rules, generally context-independent
        Returns:
        the contextual DateTimeFormatter