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
?
Joda-Time provides a quality replacement for the Java date and time classes. Joda-Time is the de facto standard date and time library for Java prior to Java SE 8. Users are now asked to migrate to java. time (JSR-310). Joda-Time is licensed under the business-friendly Apache 2.0 licence.
An interval in Joda-Time represents an interval of time from one instant to another instant. Both instants are fully specified instants in the datetime continuum, complete with time zone.
Joda-Time is an API created by joda.org which offers better classes and having efficient methods to handle date and time than classes from java. util package like Calendar, Gregorian Calendar, Date, etc. This API is included in Java 8.0 with the java.
Use DateTime#toDate()
.
Date date = dateTime.toDate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With