cats-effect-time - Java Time from Cats-Effect Maven Central

Quick Start

To use cats-effect-time in an existing SBT project with Scala 2.12 or a later version, add the following dependencies to your build.sbt depending on your needs:

libraryDependencies ++= Seq(
  "io.chrisdavenport" %% "cats-effect-time" % "<version>"
)

Example

import cats.effect._
import io.chrisdavenport.cats.effect.time.JavaTime

// For Display Purposes Only
// Do Not Use In Production Code
import cats.effect.unsafe.implicits.global

// Works with a valid Functor and Clock in scope
val currentTimeOp = JavaTime[IO].getInstant
// currentTimeOp: IO[Instant] = Map(
//   ioe = IO(...),
//   f = io.chrisdavenport.cats.effect.time.JavaTime$ClockJavaTime$$Lambda$11256/0x0000000102e71840@2c86b006,
//   event = cats.effect.tracing.TracingEvent$StackTrace
// )

currentTimeOp.unsafeRunSync()
// res0: Instant = 2026-09-25T18:06:56.222Z

// Or you can use it implicitly
import io.chrisdavenport.cats.effect.time.implicits._

val currentTime = Clock[IO].getZonedDateTimeUTC
// currentTime: IO[ZonedDateTime] = Map(
//   ioe = Map(
//     ioe = IO(...),
//     f = io.chrisdavenport.cats.effect.time.JavaTime$ClockJavaTime$$Lambda$11256/0x0000000102e71840@2c86b006,
//     event = cats.effect.tracing.TracingEvent$StackTrace
//   ),
//   f = io.chrisdavenport.cats.effect.time.JavaTime$ClockJavaTime$$Lambda$11308/0x0000000102ea0040@3dded24d,
//   event = cats.effect.tracing.TracingEvent$StackTrace
// )
currentTime.unsafeRunSync()
// res1: ZonedDateTime = 2026-09-25T18:06:56.226Z