开发者

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?


Use DateTime#toDate().

Date date = dateTime.toDate();


One way to do that is: Extract milli-seconds from joda-datetime instance and then pass it to java.util.Date constructor.

Date date = new java.util.Date(jodaDateTime.getMillis())
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜