This page is no longer maintained — Please continue to the home page at www.scala-lang.org

scala-time question

No replies
Eduardo M. Cava...
Joined: 2011-04-08,
User offline. Last seen 42 years 45 weeks ago.

Hi,
I have 2 LocalDates and I want the difference in days between them.

val d1: LocalDate
val d2: LocalDate

The jodatime way of doing this could be:
Days.daysBetween(d1, d2).getDays

I was trying to get some simplification of this using scala-time,
something like:

(d2-d1).days

But d2 -d1 does not compile, gives:

"Multiple markers at this line
- overloaded method value - with alternatives: (builder:
org.scala_tools.time.DurationBuilder)org.joda.time.LocalDate (period:
org.joda.time.ReadablePeriod)org.joda.time.LocalDate cannot be
applied to (org.scala_tools.time.Imports.LocalDate)
- overloaded method value - with alternatives: (builder:
org.scala_tools.time.DurationBuilder)org.joda.time.LocalDate (period:
org.joda.time.ReadablePeriod)org.joda.time.LocalDate cannot be
applied to (org.scala_tools.time.Imports.LocalDate)"

Any advice on this?

Thank you.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland