Using Groovy(or Java) how can I convert a org.joda.time.LocalDateTime to a java.util.date?

感情迁移 提交于 2019-12-06 11:45:24

EDIT:

The problem is the use of Calendar.HOUR which indicates the hour of the morning or afternoon.

Either use:

cal.set(Calendar.HOUR_OF_DAY, 0)

or:

cal.set(Calendar.AM_PM, Calendar.AM)
cal.set(Calendar.HOUR, 0)

Somewhere during the conversion, the wrong time zone is being used. Debug this by seeing what the default time zone is TimeZone.getDefault() and what the Joda-Time default is DateTimeZone.getDefault().

You can be more explicit when doing the conversion too:

localDateTime.toDateTime(yourDesiredZone).toDate()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!