Package org.apache.cassandra.db.marshal
Class TemporalType<T>
- java.lang.Object
-
- org.apache.cassandra.db.marshal.AbstractType<T>
-
- org.apache.cassandra.db.marshal.TemporalType<T>
-
- All Implemented Interfaces:
java.util.Comparator<java.nio.ByteBuffer>,AssignmentTestable
- Direct Known Subclasses:
AbstractTimeUUIDType,SimpleDateType,TimestampType,TimeType
public abstract class TemporalType<T> extends AbstractType<T>
Base type for temporal types (timestamp, date ...).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.db.marshal.AbstractType
AbstractType.ComparisonType
-
Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.AssignmentTestable
AssignmentTestable.TestResult
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTemporalType(AbstractType.ComparisonType comparisonType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBufferaddDuration(java.nio.ByteBuffer temporal, java.nio.ByteBuffer duration)Adds the duration to the specified value.java.nio.ByteBufferfromTimeInMillis(long timeInMillis)Returns the temporal value corresponding to the specified UNIX timestamp.java.nio.ByteBuffernow()Returns the current temporal value.java.nio.ByteBuffersubstractDuration(java.nio.ByteBuffer temporal, java.nio.ByteBuffer duration)Substract the duration from the specified value.longtoTimeInMillis(java.nio.ByteBuffer value)Converts this temporal in UNIX timestamp.protected voidvalidateDuration(Duration duration)Validates that the duration has the correct precision.-
Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
asCQL3Type, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareCustom, compareForCQL, compose, compose, decompose, decomposeUntyped, expandUserTypes, freeze, freezeNestedMulticellTypes, fromJSONObject, fromString, getComponents, getSerializer, getString, getString, getString, isCollection, isCompatibleWith, isCounter, isEmptyValueMeaningless, isFreezable, isFrozenCollection, isMultiCell, isReversed, isSerializationCompatibleWith, isTuple, isUDT, isValueCompatibleWith, isValueCompatibleWithInternal, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toCQLString, toJSONString, toJSONString, toString, toString, udfType, unwrap, validate, validate, validateCellValue, validateCollectionMember, valueLengthIfFixed, withUpdatedUserType, writeValue, writeValue, writtenLength, writtenLength
-
-
-
-
Constructor Detail
-
TemporalType
protected TemporalType(AbstractType.ComparisonType comparisonType)
-
-
Method Detail
-
now
public java.nio.ByteBuffer now()
Returns the current temporal value.- Returns:
- the current temporal value.
-
toTimeInMillis
public long toTimeInMillis(java.nio.ByteBuffer value)
Converts this temporal in UNIX timestamp.- Parameters:
value- the temporal value.- Returns:
- the UNIX timestamp corresponding to this temporal.
-
fromTimeInMillis
public java.nio.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 java.nio.ByteBuffer addDuration(java.nio.ByteBuffer temporal, java.nio.ByteBuffer duration)Adds the duration to the specified value.- Parameters:
temporal- the value to add toduration- the duration to add- Returns:
- the addition result
-
substractDuration
public java.nio.ByteBuffer substractDuration(java.nio.ByteBuffer temporal, java.nio.ByteBuffer duration)Substract the duration from the specified value.- Parameters:
temporal- the value to substract fromduration- 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.
-
-