Convert from java.util.date to JodaTime

Krt_Malta picture Krt_Malta · Feb 18, 2011 · Viewed 192.6k times · Source

I want to convert a java.util.Date to JodaTime so as to carry out subtractions between dates. Is there a good concise way to convert from Date to JodaTime?

Answer

skaffman picture skaffman · Feb 18, 2011
java.util.Date date = ...
DateTime dateTime = new DateTime(date);

Make sure date isn't null, though, otherwise it acts like new DateTime() - I really don't like that.