How to convert DateTime to Date

user93796 picture user93796 · Jun 17, 2009 · Viewed 81.7k times · Source

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.

Answer

skaffman picture skaffman · Jun 17, 2009

Is this Joda Time's DateTime you're talking about? If so, it will be

dateTime.toDate()