Java – How to convert DateTime to Date

datetimejavajodatime

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.

Best Solution

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

dateTime.toDate()