Calculating the difference between two Java date instances
问题 I'm using Java's java.util.Date class in Scala and want to compare a Date object and the current time. I know I can calculate the delta by using getTime(): (new java.util.Date()).getTime() - oldDate.getTime() However, this just leaves me with a long representing milliseconds. Is there any simpler, nicer way to get a time delta? 回答1: The JDK Date API is horribly broken unfortunately. I recommend using Joda Time library. Joda Time has a concept of time Interval: Interval interval = new Interval