Reputation: 64227
In a Scala 2.8 program of mine I use joda-time with its scala-time wrapper. I've got 2 DateTime values, one for a date (with zero time fields) and one for time (with zero date fields) (the reason of separation is a storage architecture).
How do I get another DateTime value with both date and time parts set from a source pair?
Upvotes: 3
Views: 1095
Reputation: 1502036
You should be using LocalDate
for the date and LocalTime
for the time. Those are the appropriate types for dates and times respectively. You can get each from a DateTime
with DateTime.toLocalDate()
and DateTime.toLocalTime()
if you have to have them as DateTime
values to start with. Ideally you wouldn't build a DateTime
at all until you've got both bits separately though :)
Then you can LocalDate.toDateTime(LocalTime, DateTimeZone)
.
Upvotes: 10