views:

64

answers:

1

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?

+5  A: 

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).

Jon Skeet
I don't want LOCAL time. In this project I use strict "Zulu" UTC only.
Ivan
@Ivan, `LocalDate is an immutable datetime class representing a date without a time zone.`
matt b