Class TemporalContext<T extends java.time.temporal.Temporal>

  • All Implemented Interfaces:
    TypeContext<T>

    public final class TemporalContext<T extends java.time.temporal.Temporal>
    extends java.lang.Object
    implements TypeContext<T>
    An implementation of TypeContext that is implemented in terms of DateTimeFormatter and TemporalAdjuster.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.time.temporal.TemporalAdjuster myAdjuster  
      private java.time.format.DateTimeFormatter myFormatter  
    • Constructor Summary

      Constructors 
      Constructor Description
      TemporalContext​(java.time.format.DateTimeFormatter formatter, java.time.temporal.TemporalAdjuster adjuster)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T enforce​(T object)
      Will force the object to conform to the context's specification.
      java.lang.String format​(java.lang.Object object)  
      static <T extends java.time.temporal.Temporal>
      TemporalContext<T>
      of​(java.time.format.DateTimeFormatter formatter)  
      static <T extends java.time.temporal.Temporal>
      TemporalContext<T>
      of​(java.time.format.DateTimeFormatter formatter, java.time.temporal.TemporalAdjuster adjuster)  
      T parse​(java.lang.CharSequence text)  
      TemporalContext<T> withAdjuster​(java.time.temporal.TemporalAdjuster adjuster)  
      TemporalContext<T> withFormatter​(java.time.format.DateTimeFormatter formatter)  
      • Methods inherited from class java.lang.Object

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

      • myAdjuster

        private final java.time.temporal.TemporalAdjuster myAdjuster
      • myFormatter

        private final java.time.format.DateTimeFormatter myFormatter
    • Constructor Detail

      • TemporalContext

        TemporalContext​(java.time.format.DateTimeFormatter formatter,
                        java.time.temporal.TemporalAdjuster adjuster)
    • Method Detail

      • of

        public static <T extends java.time.temporal.Temporal> TemporalContext<T> of​(java.time.format.DateTimeFormatter formatter)
      • of

        public static <T extends java.time.temporal.Temporal> TemporalContext<T> of​(java.time.format.DateTimeFormatter formatter,
                                                                                    java.time.temporal.TemporalAdjuster adjuster)
      • enforce

        public T enforce​(T object)
        Description copied from interface: TypeContext
        Will force the object to conform to the context's specification. The default implementation formats a String and then parses that back to an object (of the original type).
        Specified by:
        enforce in interface TypeContext<T extends java.time.temporal.Temporal>
      • format

        public java.lang.String format​(java.lang.Object object)
        Specified by:
        format in interface TypeContext<T extends java.time.temporal.Temporal>
      • parse

        public T parse​(java.lang.CharSequence text)
        Specified by:
        parse in interface TypeContext<T extends java.time.temporal.Temporal>
      • withAdjuster

        public TemporalContext<T> withAdjuster​(java.time.temporal.TemporalAdjuster adjuster)
      • withFormatter

        public TemporalContext<T> withFormatter​(java.time.format.DateTimeFormatter formatter)