[Java] Calendar Date to Timestamp

In Java you can convert a Date to a Timestamp simply by:

Date date = Calendar.getInstance().getTime();

This will return the current date, then:

Timestamp timestamp = new Timestamp(date.getTime());

where date.getTime() will return a long.

No comments:

Post a Comment

With great power comes great responsibility.

Da grandi poteri derivano grandi responsabilità.