You can create Joda DateTime object from the Java Date object, since Java does not have a DateTime
class.
DateTime dt = new DateTime(start.getTime());
Though the Date
class of Java holds the time information as well(that's what you need in the first place), I suggest you to use a Calendar
instead of the Date
class of Java.
Calendar myCal = new GregorianCalendar();
myCal.setTime(date);
Have a look at the Calendar docs for more info on how you can use it more effectively.
Things have changed and now even Java (Java 8 to be precise), has a LocalDateTime and ZonedDateTime class. For conversions, you can have a look at this SO answer(posting an excerpt from there).
Given: Date date = [some date]
(1) LocalDateTime << Instant<< Date
Instant instant = Instant.ofEpochMilli(date.getTime());
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
(2) Date << Instant << LocalDateTime
Instant instant = ldt.toInstant(ZoneOffset.UTC);
Date date = Date.from(instant);
Date
also has time information. – HypomaniaDateTime
class. UseDate
. – Hypomaniajava.util.Date
,java.util.Calendar
, andjava.text.SimpleDateFormat
are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle. – Masked