DEV Community

Erik Christensen
Erik Christensen

Posted on • Updated on

Introducing Island Time - A Kotlin Multiplatform library for working with dates and times

One major gap when writing multiplatform Kotlin code so far has been the lack of a quality date and time library. That is to say, something that doesn't feel like a big step backwards for those used to working with java.time or the ThreeTen backport.

Island Time is a project that seeks to rectify this situation. It's inspired heavily by the java.time library, embracing many of the core classes and concepts. But it's not a strict port either, taking inspiration from other date-time libraries as well with the goal being to (ultimately) create a powerful library that enables a wide array of use cases while providing a more friendly, extension-oriented API that takes full advantage of Kotlin language features.

It's still early days, but I'm pleased to announce the first versioned release -- 0.1.0.

Some of the current features include:

  • A set of date-time primitives such as Date, Time, DateTime, Instant, and ZonedDateTime
  • Time zone database support
  • Date ranges and time intervals, integrating with Kotlin ranges and progressions
  • Read and write strings in ISO formats
  • DSL-based definition of custom parsers
  • Operators like or dateTime.startOfWeek
  • Works on JVM, Android, iOS, and macOS

Of course, there are limitations. Most notably:

  • No custom and/or localized format strings
  • No localized week fields
  • Only supports the ISO calendar system
  • Year range currently restricted to 1-9999
  • No Javascript support

You can find a lot more information on the Github page.

Development is "moving fast" and the API is likely to experience changes. In its current state though, it's a quite usable library that I suspect might satisfy the needs of quite a few of you. It certainly unblocked me in taking a chunk of my own Android app's code and making it multiplatform-friendly.

Feedback is much appreciated. There are plenty of warts and design issues that are yet to be resolved and your comments -- and contributions, if you're so inclined -- can all help make this a better library.

Discussion (0)