I want to convert Joda LocalTime to java.util.Date and not LocalDate. If this helps, I already have a LocalTime object with me. Obviously, there is no "date" part in LocalTime. So I cannot convert LocalTime to Date directly. 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();
Have you tried
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.
DateTimeZone.getDefault() will return the local zone of the system.
来源:https://stackoverflow.com/questions/15543031/how-to-convert-joda-time-localtime-to-java-util-date