Jayashree Jayashree - 1 year ago 542
Java Question

How can we convert com.datastax.driver.core.LocalDate to java.util.Date?

I am working with dates.

Datastax's CQL cassandra API

returns a

I want to convert the
object returned by the API to
. How can I do that?


The LocalDate.getMillisSinceEpoch() Javadoc says Returns the number of milliseconds since January 1st, 1970 GMT. And, the Date(long) constructor Javadoc says Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT. So, given a LocalDate ld you should be able to do something like

Date d = new Date(ld.getMillisSinceEpoch());