Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get java.util.Date out from Joda-Time DateTime

Tags:

java

jodatime

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?

like image 682
Cheok Yan Cheng Avatar asked Dec 11 '10 13:12

Cheok Yan Cheng


People also ask

What is Jodatime in Java?

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.

Does Joda datetime have time zones?

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.

Is Joda-time included in Java 8?

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.


1 Answers

Use DateTime#toDate().

Date date = dateTime.toDate(); 
like image 51
BalusC Avatar answered Sep 22 '22 02:09

BalusC