pmeheut / nscala-java-time Edit

A wrapper for cquiroz/scala-java-time based on nscala-time

Version Matrix


Maven Central scaladoc

A Scala wrapper for [cquiroz/scala-java-time]. This project forked from nscala-time It was then adapted to support this Scala implementation of the Java 8 Time library instead of JodaTime hence supporting Scala.js.


Add the following to your sbt build:

libraryDependencies += "io.github.pmeheut" %%% "nscala-java-time" % "0.1.0"

Release Note


Creation from nscala-time 2.3.0


This is mostly a convenience wrapper around the Scala Java Time library, adding more pleasant syntax like operators for addition, subtraction, and comparison.


import com.github.nscala_java_time.time.Imports._

Date/Time Operations + 2.months // returns org.joda.time.DateTime = 2009-06-27T13:25:59.195-07:00

LocalDateTime.nextMonth < + 2.months // returns Boolean = true

2.hours + 45.minutes + 10.seconds // returns java.time.Duration

(2.hours + 45.minutes + 10.seconds).millis // returns Long = 9910000

2.months + 3.days // returns Period

Fluent interface // returns java.time.LocalDateTime = 2009-04-27T13:25:42.659-07:00 // returns java.time.LocalDateTime = 2009-04-27T02:45:10.313-07:00

Please see the Java 8 time API for full explanation of key concepts or


scaladoc (latest stable release)


cquiroz/scala-java-time is a great library to use the same API in ScalaJS cross-projects, especially because this is the standard Java 8 API. Adding idiomatic scala functions such as direct comparison with <, <=, etc and adding periods and durations with + is a big bonus.