Is there a way to convert a Time and Date variable to a DateTime?
I have a period between two DateTime variables, for each Date in that period I want to store a period IN that Date with a begin DateTime and end DateTime, so a day can have multiple periods defined by a DateTime.
Can't seem to figure out how to combine Date and Time to a DateTime.
Thanks in advance!
Plain java Date
and Joda-Time DateTime
should serve the purpose.
Date date = new Date(); // java.util.Date; - This date has both the date and time in it already.
DateTime dateTime = new DateTime(date);
For more info about Joda-Time.
If you have two String
objects, where 1 holds the Date
and the other Time
, you can combine the 2 Strings and use a SDF to parse it and get the Date
object, which you can then convert to DateTime
.
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