I'll be very impressed if someone can solve my problem.
I am using the Cassandra Thrift API via C#. I have a "timestamp" type column in Cassandra, which is supposed to be seconds since the Unix epoch expressed as an 8-byte long.
To convert, I do this:
BitConverter.GetBytes(ToUnixTimestamp(columnValue)));
where:
protected static long ToUnixTimestamp(DateTime dateTime)
{
return Convert.ToInt64((dateTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds);
}
When I check my value in the CLI, I see:
=> (column=created, value=225330207-01-15 03:30:53-0500, timestamp=1356568301)
Cassandra is not interpreting the value I insert correctly. The year 225330207 is not what I was inserting. Why is this happening and how do I fix this?
You need to store and retrieve values from the "timestamp" type column as milliseconds since the Unix epoch, not seconds.