8

Is there a way to convert java.sql.Date to java.sql.Timestamp?

I have the following code:

java.sql.Date = new Date();
java.sql.Timestamp timestamp = new java.sql.Timestamp(date);

But the Timestamp constructor doesn't seem to support that variable type.

1 Answers1

18

You can get the constructor that takes milliseconds as argument, like:

java.sql.Date date = new Date();
java.sql.Timestamp timestamp = new java.sql.Timestamp(date.getTime());
dan
  • 13,132
  • 3
  • 38
  • 49