[英]How to convert Joda time LocalTime to java.util.Date?
I want to convert Joda LocalTime to java.util.Date and not LocalDate. 我想将Joda LocalTime转换为java.util.Date而不是 LocalDate。 If this helps, I already have a LocalTime object with me. 如果有帮助,我已经有了一个LocalTime对象。 Obviously, there is no "date" part in LocalTime. 显然,LocalTime中没有“日期”部分。 So I cannot convert LocalTime to Date directly. 因此,我无法将LocalTime直接转换为Date。 Is there a simple way to do this ? 有没有简单的方法可以做到这一点?
Steps - 脚步 -
LocalTime loct
LocalDate locd = Todays date + loct
Date da = locd.toDate();
Date da = loct.toDateTimeToday().toDate();
你有没有尝试过
locd.withFields(loct).toDate();
You can also use this-- 您也可以使用-
Date dtUtil = DateTime.now(DateTimeZone.getDefault()).toDate();
the generic way is - 通用方式是-
Date dtUtil = DateTime.now(DateTimeZone.forID("TimeZoneString")).toDate();
where "TimeZoneString"is timeZone id for which you want to get the time. 其中“ TimeZoneString”是您要获取其时间的timeZone ID。
DateTimeZone.getDefault() will return the local zone of the system. DateTimeZone.getDefault()将返回系统的本地区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.