reactivecodes / scala-time

Scala friendly wrapper for java.time and ThreeTen BP

GitHub

scala-time

Basic Scala utilities allowing for easier use of java.time APIs.

Note: Support has now been dropped for JDK 7 and the Threeten BP backport APIs.

Supported Scala Versions:
  • 2.12
  • 2.11
  • 2.10


Usage:

This project is not yet considered stable, and the API is subject to change, however version 0.4.1 binaries are published to the Maven Central public repository.

sbt coordinates:
    // Requires JDK 1.8 and above
    "codes.reactive" %% "scala-time" % "0.4.1"

Documentation:

See the project website for links to current documentation.

Examples:

import java.time._
import codes.reactive.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 a default TemporalQuery for precision
val query = temporal.TemporalQueries.precision

// 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 |> localDate

License

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.