« Back to blog

Cassandra Column Timestamp

Cassandra uses the timestamp value of Columns for conflict resolution. When it comes to Columns, Cassandra requires that the client application provide the value of the timestamp. For this reason it’s important that client applications maintain synchronized clocks. The timestamp value by convention is the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC (Unix epoch).

Below is a simple example that sets the timestamp property of the Thrift API Column object, with the current time in milliseconds.

Column description = new Column();
description.setName(“description”.getBytes());
description.setValue(“some description”.getBytes());
description.setTimestamp(System.currentTimeMillis());

Make sure your Cassandra clients have synchronized clocks and don’t forget to set the Timestamp of your Columns.