Reputation: 16729
I notice that if my model has a field expirationTime
of type DateTime
then I cannot store it iin timestamp
field in Cassandra
.
QueryBuilder.set("expiration_time",model.expirationTime) //data gets corrupted
But if I store time as milli seconds
then it works.
QueryBuilder.set("expiration_time",model.expirationTime.getMillis()) //WORKS
Question 1 - Does that mean that the timestamp
field in cassandra
is of type long
?
Question2 - Is it cqlsh
which converts the time into readable format like 2018-05-18 03:21+0530
??
Upvotes: 2
Views: 5776
Reputation: 87069
From DataStax documentation on CQL types:
Date and time with millisecond precision, encoded as 8 bytes since epoch. Can be represented as a string, such as 2015-05-03 13:30:54.234.
In Java as input you can use either long with milliseconds, or string literal, supported in CQL, or java.util.Date
(see the code). When reading, results mapped into java.util.Date
in driver 3.x/1.x (see full table for CQL<->Java types mapping), or to the java.time.Instant
in the driver 4.x/2.x (see CQL<->Java types mapping).
In Python/cqlsh, yes - the data is read as 8-byte long, then is then converted into string representation.
Upvotes: 3