Last active
December 25, 2015 01:39
-
-
Save NIA/6897097 to your computer and use it in GitHub Desktop.
Getting time diffs using https://github.com/scalaj/scalaj-time (JodaTime wrapper for scala)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.9.2" | |
mainClass := Some("Main") | |
libraryDependencies += "org.scalaj" %% "scalaj-time" % "0.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// locate this in src/main/scala/ to compile with sbt | |
import org.joda.time.Period | |
import org.joda.time.format.PeriodFormat | |
import org.scala_tools.time.Imports._ | |
object Main extends App { | |
def periodDiff(t1: Period)(t2: Period) = PeriodFormat.getDefault print (t1 - t2).normalizedStandard | |
println( periodDiff(2.hours + 14.minutes + 39.seconds)(1.hour + 32.minutes + 43.seconds) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment