Class TemporalType<T>

java.lang.Object
org.apache.cassandra.db.marshal.AbstractType<T>
org.apache.cassandra.db.marshal.TemporalType<T>
All Implemented Interfaces:
Comparator<ByteBuffer>, AssignmentTestable
Direct Known Subclasses:
AbstractTimeUUIDType, SimpleDateType, TimestampType, TimeType

public abstract class TemporalType<T> extends AbstractType<T>
Base type for temporal types (timestamp, date ...).
  • Constructor Details

  • Method Details

    • now

      public ByteBuffer now()
      Returns the current temporal value.
      Returns:
      the current temporal value.
    • toTimeInMillis

      public long toTimeInMillis(ByteBuffer value)
      Converts this temporal in UNIX timestamp.
      Parameters:
      value - the temporal value.
      Returns:
      the UNIX timestamp corresponding to this temporal.
    • fromTimeInMillis

      public ByteBuffer fromTimeInMillis(long timeInMillis)
      Returns the temporal value corresponding to the specified UNIX timestamp.
      Parameters:
      timeInMillis - the UNIX timestamp to convert
      Returns:
      the temporal value corresponding to the specified UNIX timestamp
    • addDuration

      public ByteBuffer addDuration(Number temporal, Duration duration)
      Adds the duration to the specified value.
      Parameters:
      temporal - the value to add to
      duration - the duration to add
      Returns:
      the addition result
    • substractDuration

      public ByteBuffer substractDuration(Number temporal, Duration duration)
      Substract the duration from the specified value.
      Parameters:
      temporal - the value to substract from
      duration - the duration to substract
      Returns:
      the substracion result
    • validateDuration

      protected void validateDuration(Duration duration)
      Validates that the duration has the correct precision.
      Parameters:
      duration - the duration to validate.
    • getArgumentDeserializer

      public ArgumentDeserializer getArgumentDeserializer()
      Overrides:
      getArgumentDeserializer in class AbstractType<T>
      Returns:
      the deserializer used to deserialize the function arguments of this type.