tags:

views:

150

answers:

3

How can I convert Date to DateTime and vice versa?

E.g.

Date dt = new Date();

Now I want to covert this to DateTime.

Also

DateTime dtim = new DateTime();

Now I want to convert it to Date.

+1  A: 

I guess you convert it to UTC via Date.getTime(). And after that, use a constructor/setter on the other object.

kd304
+1  A: 

Is this JodaTime's DateTime you're talking about? If so, it's dateTime.toDate()

skaffman
+2  A: 

Here is the Javadoc.

aberrant80