Cheok Yan Cheng Cheok Yan Cheng - 6 days ago 7
Java Question

Get java.util.Date out from Joda-Time DateTime

I have code like this:

// old_api(Date date)
old_api(calendar.getTime());


Currently, I need to replace
Calendar
with Joda-Time
DateTime
. I was wondering how I can get
java.util.Date
out from Joda-Time
DateTime
?

Answer

Use DateTime#toDate().

Date date = dateTime.toDate();