[java] Java Timestamp - How can I create a Timestamp with the date 23/09/2007?

How can I create a Timestamp with the date 23/09/2007?

This question is related to java datetime timestamp date

The answer is


By Timestamp, I presume you mean java.sql.Timestamp. You will notice that this class has a constructor that accepts a long argument. You can parse this using the DateFormat class:

DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateFormat.parse("23/09/2007");
long time = date.getTime();
new Timestamp(time);

Similar questions with java tag:

Similar questions with datetime tag:

Similar questions with timestamp tag:

Similar questions with date tag: