Basic Scala utilities allowing for easier use of java.time
compatible APIs, with the aim of providing a single
Scala API (and migration point) between JDK 1.8 Time, and the Threeten BP JDK 7 backport.
- 2.11
- 2.10
This project is not yet considered stable, and the API is subject to change, however 0.3.0-SNAPSHOT
binaries are
published to the Sonatype OSS Snapshots
public repository.
sbt coordinates:
// If using JDK 1.8 and above
"codes.reactive" %% "scala-time" % "0.3.0-SNAPSHOT"
// If using JDK 1.7
"codes.reactive" %% "scala-time-threeten" % "0.3.0-SNAPSHOT"
See the project website for links to current documentation.
import codes.reactive.scalatime._
import Scalatime._
// Obtain a Duration instance from a Long
val duration = 10L minutes
val otherDuration = 1L minute
// Obtain a Period instance from an Int
val period = 2 weeks
// Obtains a LocalDate instance
val localDate = LocalDate.of(2014, 6, 7)
// Obtain the current UTC ZonedDateTime
val zonedDateTime = ZonedDateTime()
// Obtain a default TemporalQuery for the ZoneId
val query = temporal.TemporalQuery.zone
// Obtain a Duration instance from a sum of Durations
duration + otherDuration
// Add a TemporalAmount to a Temporal
period <<+ localDate
// Add a TemporalAmount to a Temporal
localDate + period
// Subtract a TemporalAmount from a Temporal
localDate - period
// Query a specified Temporal
val result = query |> zonedDateTime
See the NOTICE file distributed with this work for additional information regarding copyright ownership
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.