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?
You should be using
LocalDatefor the date andLocalTimefor the time. Those are the appropriate types for dates and times respectively. You can get each from aDateTimewithDateTime.toLocalDate()andDateTime.toLocalTime()if you have to have them asDateTimevalues to start with. Ideally you wouldn’t build aDateTimeat all until you’ve got both bits separately though 🙂Then you can
LocalDate.toDateTime(LocalTime, DateTimeZone).