Git Product home page Git Product logo

scala-java-time's Introduction

Scala Java-Time

build Maven Central Scala.js

This project provides an implementation of the java.time package, a date and time library that was added in Java 8. The implementation is based on the original BSD-licensed reference implementation (before it was contributed to OpenJDK).

Usage

The scala-java-time library is currently available for Scala (JVM, version 8 and later), Scala.js (JavaScript) and Scala Native (LLVM). Scala 2.11, Scala 2.12, Scala 2.13 and Scala 3.0.0 are supported.

To get started with SBT, add one (or both) of these dependencies:

  • libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.5.0"

Documentation

See the documentation

scala-java-time's People

Contributors

armanbilge avatar barend-xebia avatar bwbecker avatar cquiroz avatar daxten avatar dependabot[bot] avatar easel avatar fabfas avatar fabiokung avatar felher avatar graben avatar hedefalk avatar jespersm avatar jodastephen avatar jpgough avatar keithharris avatar kemokid avatar lvitaly avatar marcadella avatar pamalyshev avatar renjith4 avatar richardwarburton avatar rogerriggs avatar scala-steward avatar sideeffffect avatar sjmisterm avatar soc avatar sschaap avatar sullis avatar toadzky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

scala-java-time's Issues

Regression test for 2.0.0-RC5

The following tests used to work with dependencies

    "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M13",
    "io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.0.0-M13_2018c", // ToDo: filter timezones

but fail with dependencies

    "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-RC5",
    "io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.0.0-RC3_2019a", // ToDo: filter timezones
     "with predefined formatters" - {
        "formatFullDate" - {
          assertResult("January 30, 2018") {dt.format(formatFullDate)}
        }
        "formatDayOfWeek" - {
          assertResult("Tuesday Jan. 30") {dt.format(formatDayOfWeek)}
        }
        "formatTime_AM_PM" - {
          assertResult("11:02 AM") {dt.format(formatTime_AM_PM)}
        }
      }

where dt is defined as LocalDateTime.of(2018, 1, 30, 11, 2, 45, 750000)
and the formatters as

  val formatFullDate = DateTimeFormatter.ofPattern("MMMM dd, yyyy")

  val formatDayOfWeek = DateTimeFormatter.ofPattern("cccc MMM. d")   // Thursday Jan. 25

  val formatTime_AM_PM = DateTimeFormatter.ofPattern("h:mm a")    // 10:15 PM

The output I'm now getting from the tests is

X oat.xplatform.javaTime.JavaTimeTests.Formatting LocalDateTime.with predefined formatters.formatFullDate 4ms
  utest.AssertionError: utest.assert(actual == expected)
  actual: Any = M01 30, 2018
  expected: T = January 30, 2018
X oat.xplatform.javaTime.JavaTimeTests.Formatting LocalDateTime.with predefined formatters.formatDayOfWeek 3ms
  utest.AssertionError: utest.assert(actual == expected)
  actual: Any = Tue . 30
  expected: T = Tuesday Jan. 30
X oat.xplatform.javaTime.JavaTimeTests.Formatting LocalDateTime.with predefined formatters.formatTime_AM_PM 2ms
  utest.AssertionError: utest.assert(actual == expected)
  actual: Any = 11:02
  expected: T = 11:02 AM

I spent some time with the scala-java-time code to see if I could at least write a test, but couldn't get it figured out in a reasonable amount of time. Sorry.

Thanks for your fantastic work.

Missing methods for JDK9+

While using java.time.Duration, several methods added after Java 8 was not implemented.
For example:

  • public long dividedBy(Duration divisor)
  • public int to*Part()

I assume there are a few more scattered around in java.time.

The implementation for most of them are trivial.
I'm not sure whether the licence allows copying and pasting directly from OpenJDK source.
If it is, I'll just open a PR and fill in all the new methods.

ZoneRulesException without timezone

The following code works in scala: LocalDateTime.now().
But in Scalajs it throws: java.time.zone.ZoneRulesException: Unknown time-zone ID: Europe/Oslo.
I do not intend to use any timezone.
Scalajs version: 1.5.0
scala-java-time version: 2.1.0

Remove java.util.Calendar

scala-java-time contains a half-baked implementation of java.util.Calendar. That class is fairly large and contains many quirks, completing it will be a major task. Instead I propose to remove it, leaving only the static constants. The current implementation contains a minimum of code to support some parts of the code

Inspection of the code reveal this change will involve moving the JapaneseChronology and JapaneseEra classes to be jvm only. At any rate given how broken Calendar is, they likely don't work properly

IMHO we shouldn't ship classes not properly implemented

Scala Native 0.5 release

Is the release for 0.5 planned anytime soon? With the libraries slowly publishing for it, the lack of scala-java-time for 0.5 would be a blocker for some libraries.

3.x compilation

scala-java-time is a dependency for zio and zio now has 3.x support.

Anyway to add 3.x published supported for scala-java-time? While withDottyCompat will probably work, it would be good to get this lib on track for the 3.x series.

Same comment for scala-java-time-tzb.

ZoneId parsing error messages differ from those of java.time

For example, on the JVM:

scala> java.time.ZoneId.of("X")
java.time.DateTimeException: Invalid ID for ZoneOffset, invalid format: X
  at java.base/java.time.ZoneOffset.of(ZoneOffset.java:241)
  at java.base/java.time.ZoneId.of(ZoneId.java:402)
  at java.base/java.time.ZoneId.of(ZoneId.java:356)
  ... 36 elided

While with scala-java-time on Scala.js the message is Invalid zone: X.

Proposal for JS for implementing .now() without tzdb for all "time" classes except for ZonedDateTime

With these helpers on JS (browsers, node.js), we obtain an OffsetDateTime.now() equivalent (of course up to millisecond resolution due to JS nature) without the need to add tzdb. This unlocks all of {LocalDate, LocalDateTime, LocalTime, MonthDay, OffsetDateTime, OffsetTime, Year, YearMonth}.now() straightforward implementations in terms of the OffsetDateTime.now() instance. And only ZonedDateTime, which intuitively should be the only one that requires actual tz data is left with that need.

def utcOffsetSeconds(ms: Long) = -new Date(ms.toDouble).getTimezoneOffset().toInt * 60

def offsetDateTimeInDefaultTimeZone(instant: Instant) = instant.atOffset(ZoneOffset.ofTotalSeconds(utcOffsetSeconds(instant.toEpochMilli)))

def offsetDateTimeInDefaultTimeZoneNow() = offsetDateTimeInDefaultTimeZone(Instant.now())

What do you think about this?

OffsetDateTime.now not emitting error anymore, but works wrong

Hi,
first of all million thanks for getting tz support out! Dunno if this is really a bug or just a feature which is still missing:

using scalajs OffsetDateTime.now is not throwing an error anymore, but the system default offset seems to be calculated wrong (or not at all?), it will always be +00 as it seems

any expected but <notype> found for tree of type org.scalajs.ir.Trees$Block

Hi, I'm having an issue in scala-java-time/core/js/target/scala-3.0.0/src_managed/main/org/threeten/bp/format/DateTimeFormatterBuilder.scala(1536:4:Labeled)

The error given is: any expected but found for tree of type org.scalajs.ir.Trees$Block

Any ideas on how to solve this?

Using scala version 3.0.0
and version: 2.3.0 of this library

Thank you

Thank You!

Carlos -- Just wanted to say a huge "Thank you" for all the work you've put into scala-java-time. I'm in the midst of converting my project to use it. It is cleaning up a mountain of past heartaches. Thanks!

Byron

UndefinedBehaviorError: java.lang.ArrayIndexOutOfBoundsException: 0

import java.time.LocalDateTime
import java.time.format.DateTimeFormatterBuilder
import java.time.temporal.ChronoField
import java.time.format.TextStyle
import java.util.Locale
import java.time.format.DateTimeFormatter
import java.time.LocalDate
import java.time.ZoneId

val formatterFull: DateTimeFormatter = new DateTimeFormatterBuilder()
    .appendPattern("dd ")
    .appendText(ChronoField.MONTH_OF_YEAR, TextStyle.FULL_STANDALONE)
    .toFormatter(Locale.forLanguageTag("uk"))
val today = LocalDate.now(ZoneId.of("UTC"))
val todayString = today.format(formatterFull)
print(todayString)

This code works on JVM but fails with UndefinedBehaviorError on Scala.js

It would be nice to get rid of scala-reflect

Hi,

I'm running my Scala apps on AWS Lambda and there is a very strict limit on classpath jars size. scala-java-time is the only library which depends on scala-reflect.

From what I can see it should be possible to remove reflection. Could you please consider that?

Linking issue with scala-java-time-tzdb 2.0.0-RC4_2019c on scala.js 0.6.32

Hi,

I tried to update scala-java-time-tzdb to the latest version and get this linking error on scala.js 0.6.32.

org.scalajs.core.ir.IRVersionNotSupportedException: Failed to deserialize info of file compiled with Scala.js 1.0 (supported: 0.6.0, 0.6.13, 0.6.3, 0.6.17, 0.6.4, 0.6.6, 0.6.14,
 0.6.8, 0.6.30, 0.6.29, 0.6.5, 0.6.15):/path-to-maven-cache/io/github/cquiroz/scala-java-time-tzdb_sjs0.6_2.12/2.0
.0-RC4_2019c/scala-java-time-tzdb_sjs0.6_2.12-2.0.0-RC4_2019c.jar:zonedb/java/tzdb$ameor.sjsir
[error]         at org.scalajs.core.tools.io.VirtualSerializedScalaJSIRFile.info(VirtualFiles.scala:165)
[error]         at org.scalajs.core.tools.io.VirtualSerializedScalaJSIRFile.info$(VirtualFiles.scala:156)
[error]         at org.scalajs.core.tools.io.MemVirtualSerializedScalaJSIRFile.info(MemFiles.scala:107)
[error]         at org.scalajs.core.tools.io.IRFileCache$PersistentIRFile.<init>(IRFileCache.scala:247)
[error]         at org.scalajs.core.tools.io.IRFileCache$PersistedFiles.$anonfun$update$5(IRFileCache.scala:222)
[error]         at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)
[error]         at scala.collection.immutable.List.foreach(List.scala:392)
[error]         at scala.collection.TraversableLike.map(TraversableLike.scala:238)
[error]         at scala.collection.TraversableLike.map$(TraversableLike.scala:231)

Experiment with TC39 Temporal proposal

This is a proposal for a JS-native date/time API:

We should investigate implementing the java.time.* APIs in terms of Temporal. If successful, it may improve performance and more importantly help solve #69 by reducing the size of the generated JS code.

Although the Temporal APIs are not yet available it is in the process of implementation in browsers and the API is not expected to change.

There are currently polyfills which we can target for initial experiments. In http4s/http4s-dom#30 (comment) I estimated the size of scala-java-time to be roughly 100kb; meanwhile, this polyfill boasts a size of 15 kb. So that's something to think about :)

Update to Scala.js 0.6.16

Should update to the latest version of scala.js, seeing as 0.6.16 is also the last bin compatible version in the 0.6.x series of scala.js

Isues with parsing

From zio/zio-schema#579 (comment)

False negatives:

Error parsing time 00:00:00 AM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '00:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 00:00:00 AM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '00:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 01:01:00 AM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '01:01:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 01:01:00 AM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '01:01:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 10:00:00 AM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '10:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 12:00:00 PM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '12:00:00 PM' could not be parsed, unparsed text found at index 9
Error parsing time 12:09:09 PM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '12:09:09 PM' could not be parsed, unparsed text found at index 9
Error parsing time 12:59:59 PM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '12:59:59 PM' could not be parsed, unparsed text found at index 9
Error parsing time 13:09:09 PM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '13:09:09 PM' could not be parsed, unparsed text found at index 9
Error parsing time 20:20:20 PM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '20:20:20 PM' could not be parsed, unparsed text found at index 9
Error parsing time 22:22:22 PM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '22:22:22 PM' could not be parsed, unparsed text found at index 9
Error parsing time 23:59:00 PM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '23:59:00 PM' could not be parsed, unparsed text found at index 9
Error parsing time 23:59:59 PM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '23:59:59 PM' could not be parsed, unparsed text found at index 9
Error parsing time 24:00:00 AM with format HH:mm:ss a: java.time.format.DateTimeParseException: Text '24:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 0:0:0 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '0:0:0 AM' could not be parsed, unparsed text found at index 6
Error parsing time 1:1:1 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '1:1:1 AM' could not be parsed, unparsed text found at index 6
Error parsing time 00:00:00 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '00:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 00:00:00 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '00:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 01:01:00 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '01:01:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 01:01:00 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '01:01:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 10:00:00 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '10:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 12:00:00 PM with format H:m:s a: java.time.format.DateTimeParseException: Text '12:00:00 PM' could not be parsed, unparsed text found at index 9
Error parsing time 12:09:09 PM with format H:m:s a: java.time.format.DateTimeParseException: Text '12:09:09 PM' could not be parsed, unparsed text found at index 9
Error parsing time 12:59:59 PM with format H:m:s a: java.time.format.DateTimeParseException: Text '12:59:59 PM' could not be parsed, unparsed text found at index 9
Error parsing time 13:09:09 PM with format H:m:s a: java.time.format.DateTimeParseException: Text '13:09:09 PM' could not be parsed, unparsed text found at index 9
Error parsing time 20:20:20 PM with format H:m:s a: java.time.format.DateTimeParseException: Text '20:20:20 PM' could not be parsed, unparsed text found at index 9
Error parsing time 22:22:22 PM with format H:m:s a: java.time.format.DateTimeParseException: Text '22:22:22 PM' could not be parsed, unparsed text found at index 9
Error parsing time 23:59:00 PM with format H:m:s a: java.time.format.DateTimeParseException: Text '23:59:00 PM' could not be parsed, unparsed text found at index 9
Error parsing time 23:59:59 PM with format H:m:s a: java.time.format.DateTimeParseException: Text '23:59:59 PM' could not be parsed, unparsed text found at index 9
Error parsing time 0:00:00 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '0:00:00 AM' could not be parsed, unparsed text found at index 8
Error parsing time 1:11:00 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '1:11:00 AM' could not be parsed, unparsed text found at index 8
Error parsing time 24:00:00 AM with format H:m:s a: java.time.format.DateTimeParseException: Text '24:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 00:00:00 AM with format hh:mm:ss a: java.time.format.DateTimeParseException: Text '00:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 00:00:00 AM with format hh:mm:ss a: java.time.format.DateTimeParseException: Text '00:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 01:01:00 AM with format hh:mm:ss a: java.time.format.DateTimeParseException: Text '01:01:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 01:01:00 AM with format hh:mm:ss a: java.time.format.DateTimeParseException: Text '01:01:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 10:00:00 AM with format hh:mm:ss a: java.time.format.DateTimeParseException: Text '10:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 12:00:00 PM with format hh:mm:ss a: java.time.format.DateTimeParseException: Text '12:00:00 PM' could not be parsed, unparsed text found at index 9
Error parsing time 12:09:09 PM with format hh:mm:ss a: java.time.format.DateTimeParseException: Text '12:09:09 PM' could not be parsed, unparsed text found at index 9
Error parsing time 12:59:59 PM with format hh:mm:ss a: java.time.format.DateTimeParseException: Text '12:59:59 PM' could not be parsed, unparsed text found at index 9
Error parsing time 0:0:0 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '0:0:0 AM' could not be parsed, unparsed text found at index 6
Error parsing time 1:1:1 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '1:1:1 AM' could not be parsed, unparsed text found at index 6
Error parsing time 00:00:00 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '00:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 00:00:00 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '00:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 01:01:00 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '01:01:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 01:01:00 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '01:01:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 10:00:00 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '10:00:00 AM' could not be parsed, unparsed text found at index 9
Error parsing time 12:00:00 PM with format h:m:s a: java.time.format.DateTimeParseException: Text '12:00:00 PM' could not be parsed, unparsed text found at index 9
Error parsing time 12:09:09 PM with format h:m:s a: java.time.format.DateTimeParseException: Text '12:09:09 PM' could not be parsed, unparsed text found at index 9
Error parsing time 12:59:59 PM with format h:m:s a: java.time.format.DateTimeParseException: Text '12:59:59 PM' could not be parsed, unparsed text found at index 9
Error parsing time 0:00:00 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '0:00:00 AM' could not be parsed, unparsed text found at index 8
Error parsing time 1:11:00 AM with format h:m:s a: java.time.format.DateTimeParseException: Text '1:11:00 AM' could not be parsed, unparsed text found at index 8
Error parsing time 00:00:00 000000000 AM with format HH:mm:ss SSSSSSSSS a: java.time.format.DateTimeParseException: Text '00:00:00 000000000 AM' could not be parsed, unparsed text found at index 19
Error parsing time 01:01:00 000000001 AM with format HH:mm:ss SSSSSSSSS a: java.time.format.DateTimeParseException: Text '01:01:00 000000001 AM' could not be parsed, unparsed text found at index 19
Error parsing time 13:09:09 100000000 PM with format HH:mm:ss SSSSSSSSS a: java.time.format.DateTimeParseException: Text '13:09:09 100000000 PM' could not be parsed, unparsed text found at index 19
Error parsing time 20:20:20 123456789 PM with format HH:mm:ss SSSSSSSSS a: java.time.format.DateTimeParseException: Text '20:20:20 123456789 PM' could not be parsed, unparsed text found at index 19
Error parsing time 23:59:00 222222222 PM with format HH:mm:ss SSSSSSSSS a: java.time.format.DateTimeParseException: Text '23:59:00 222222222 PM' could not be parsed, unparsed text found at index 19
Error parsing time 24:00:00 000000000 AM with format HH:mm:ss SSSSSSSSS a: java.time.format.DateTimeParseException: Text '24:00:00 000000000 AM' could not be parsed, unparsed text found at index 19

False positives:

Time 60 with format mm should be invalid
Time 90 with format mm should be invalid
Time -1 with format m should be invalid
Time 60 with format m should be invalid
Time 90 with format m should be invalid
Time 0505 with format m should be invalid
Time 123 with format m should be invalid
Time 111 with format m should be invalid

NotImplementedError when formatting in ScalaJS

When formating a date time using the java.time. prefixed classes in ScalaJS I'm getting a NotImplementedError at method DateTimeFormatter.formatTo:

sjt_notimplemented

Can't really tell at what point inside that method the code is failing (or even if the code arrives to it) as the lack of sourcemaps in the java.time renamed classes makes it very difficult to debug. The thing is that the same code works if using org.threeten.bp. The application where this is used is a ScalaJS-only web frontend, deals with a lot of dates and times and everything else seems to work just fine, except formatting them.

Auto-generated tzdb_*.scala seems broken

I tried to compile the latest source (https://github.com/cquiroz/scala-java-time/tree/b58861fa7df8c1fec6bc881547d94e2c70992d70) and got the compilation error as below

[error] /home/vagrant/IdeaProjects/scala-java-time/tzdb/js/target/scala-2.12/src_managed/main/tzdb/tzdb_java.scala:275:25: identifier expected but '.' found.
[error]     val Africa_Abidjan: ... = js.Dynamic.literal(("s", -968), ("w", -968), ("t", ...(...(1912001, 0, -968, 0))), ("l", ...(...(1912001, 0, -968, 0))), ("r", ...()))
[error]                         ^

It is due to the generated tzdb_java.scala and tzdb_threeten.scala contains ... throughout the text.

Actual

// Auto-generated code from TZDB definitions, don't edit
package zonedb.threeten
import org.threeten.bp._
import org.threeten.bp.zone._
import scala.collection.JavaConverters._
import scala.language.postfixOps
import scala.scalajs.js

object tzdb {
  object pacli {
    val Pacific_Wallis: ... = js.Dynamic.literal(("s", 44120), ("w", 44120), ("t", ...(...(1901001, 0, 44120, 43200))), ("l", ...(...(1901001, 0, 44120, 43200))), ("r", ...()))
  }
  object asird {
    val Asia_Qyzylorda: ... = js.Dynamic.literal(("s", 15712), ("w", 15712), ("t", ...(...(1924123, 0, 15712, 14400), ...(1930172, 0, 14400, 18000), ...(1981273, 82800, 18000, 21600), ...(1982091, 0, 21600, 18000), ...(1991090, 7200, 18000, 14400), ...(1991272, 7200, 14400, 18000), ...(1992019, 7200, 18000, 21600), ...(1992089, 7200, 21600, 18000), ...(2004305, 7200, 18000, 21600))), ("l", ...(...(1924123, 0, 15712, 14400), ...(1930172, 0, 14400, 18000), ...(1981091, 0, 18000, 21600), ...(1982274, 0, 21600, 18000), ...(1983091, 0, 18000, 21600), ...(1983274, 0, 21600, 18000), ...(1984092, 0, 18000, 21600), ...(1984274, 10800, 21600, 18000), ...(1985090, 7200, 18000, 21600), ...(1985272, 10800, 21600, 18000), ...(1986089, 7200, 18000, 21600), ...(1986271, 10800, 21600, 18000), ...(1987088, 7200, 18000, 21600), ...(1987270, 10800, 21600, 18000), ...(1988087, 7200, 18000, 21600), ...(1988269, 10800, 21600, 18000), ...(1989085, 7200, 18000, 21600), ...(1989267, 10800, 21600, 18000), ...(1990084, 7200, 18000, 21600), ...(1990273, 10800, 21600, 18000), ...(1992019, 7200, 18000, 21600), ...(1992271, 10800, 21600, 18000), ...(1993087, 7200, 18000, 21600), ...(1993269, 10800, 21600, 18000), ...(1994086, 7200, 18000, 21600), ...(1994268, 10800, 21600, 18000), ...(1995085, 7200, 18000, 21600), ...(1995267, 10800, 21600, 18000), ...(1996091, 7200, 18000, 21600), ...(1996301, 10800, 21600, 18000), ...(1997089, 7200, 18000, 21600), ...(1997299, 10800, 21600, 18000), ...(1998088, 7200, 18000, 21600), ...(1998298, 10800, 21600, 18000), ...(1999087, 7200, 18000, 21600), ...(1999304, 10800, 21600, 18000), ...(2000086, 7200, 18000, 21600), ...(2000303, 10800, 21600, 18000), ...(2001084, 7200, 18000, 21600), ...(2001301, 10800, 21600, 18000), ...(2002090, 7200, 18000, 21600), ...(2002300, 10800, 21600, 18000), ...(2003089, 7200, 18000, 21600), ...(2003299, 10800, 21600, 18000), ...(2004088, 7200, 18000, 21600))), ("r", ...()))
  }
  // omitted
}

Expected

I guess that the ... would be

  • js.Dynamic as type annotation for value definition
  • js.Array as a function that receives integer arguments

as below

// Auto-generated code from TZDB definitions, don't edit
package zonedb.java
import java.time._
import java.time.zone._
import scala.collection.JavaConverters._
import scala.language.postfixOps
import scala.scalajs.js

object tzdb {
  object pacli {
    val Pacific_Wallis: js.Dynamic = js.Dynamic.literal(("s", 44120), ("w", 44120), ("t", js.Array(js.Array(1901001, 0, 44120, 43200))), ("l", js.Array(js.Array(1901001, 0, 44120, 43200))), ("r", js.Array()))
  }
  object asird {
    val Asia_Qyzylorda: js.Dynamic = js.Dynamic.literal(("s", 15712), ("w", 15712), ("t", js.Array(js.Array(1924123, 0, 15712, 14400), js.Array(1930172, 0, 14400, 18000), js.Array(1981273, 82800, 18000, 21600), js.Array(1982091, 0, 21600, 18000), js.Array(1991090, 7200, 18000, 14400), js.Array(1991272, 7200, 14400, 18000), js.Array(1992019, 7200, 18000, 21600), js.Array(1992089, 7200, 21600, 18000), js.Array(2004305, 7200, 18000, 21600))), ("l", js.Array(js.Array(1924123, 0, 15712, 14400), js.Array(1930172, 0, 14400, 18000), js.Array(1981091, 0, 18000, 21600), js.Array(1982274, 0, 21600, 18000), js.Array(1983091, 0, 18000, 21600), js.Array(1983274, 0, 21600, 18000), js.Array(1984092, 0, 18000, 21600), js.Array(1984274, 10800, 21600, 18000), js.Array(1985090, 7200, 18000, 21600), js.Array(1985272, 10800, 21600, 18000), js.Array(1986089, 7200, 18000, 21600), js.Array(1986271, 10800, 21600, 18000), js.Array(1987088, 7200, 18000, 21600), js.Array(1987270, 10800, 21600, 18000), js.Array(1988087, 7200, 18000, 21600), js.Array(1988269, 10800, 21600, 18000), js.Array(1989085, 7200, 18000, 21600), js.Array(1989267, 10800, 21600, 18000), js.Array(1990084, 7200, 18000, 21600), js.Array(1990273, 10800, 21600, 18000), js.Array(1992019, 7200, 18000, 21600), js.Array(1992271, 10800, 21600, 18000), js.Array(1993087, 7200, 18000, 21600), js.Array(1993269, 10800, 21600, 18000), js.Array(1994086, 7200, 18000, 21600), js.Array(1994268, 10800, 21600, 18000), js.Array(1995085, 7200, 18000, 21600), js.Array(1995267, 10800, 21600, 18000), js.Array(1996091, 7200, 18000, 21600), js.Array(1996301, 10800, 21600, 18000), js.Array(1997089, 7200, 18000, 21600), js.Array(1997299, 10800, 21600, 18000), js.Array(1998088, 7200, 18000, 21600), js.Array(1998298, 10800, 21600, 18000), js.Array(1999087, 7200, 18000, 21600), js.Array(1999304, 10800, 21600, 18000), js.Array(2000086, 7200, 18000, 21600), js.Array(2000303, 10800, 21600, 18000), js.Array(2001084, 7200, 18000, 21600), js.Array(2001301, 10800, 21600, 18000), js.Array(2002090, 7200, 18000, 21600), js.Array(2002300, 10800, 21600, 18000), js.Array(2003089, 7200, 18000, 21600), js.Array(2003299, 10800, 21600, 18000), js.Array(2004088, 7200, 18000, 21600))), ("r", js.Array()))
  }
  // ommited
}

Environment

  • Java: openjdk version "1.8.0_141"
  • sbt: 1.0.4

Update tzdb parser

As discussed on gitter

@cquiroz I got it to work by setting dbVersion := TzdbPlugin.Version("2018c") - So it seems that the tzdb format has changed in tzdb in 2018{d,e} and your parser somehow does not understand that change.
If you manually start a travis build, I bet that the tests will fail.

Thanks @ahjohannessen for reporting this

/cc @ahjohannessen

Unknown timezone id

Hi there, thanks for this library!
When I try to run my JS project, I get a "Unknown time-zone ID: Europe/London" exception.
Any idea?

Very large JS file when using Instant.ofEpochMilli

I noticed that when I want to create the current LocalDate using the following:

val offset = ZoneOffset.ofHours(0)
val date = LocalDate.now(clock)

then the generated fastOptJs file is 5.9 MB big. When I instead use

val date = LocalDate.of(2016,1,1)

then the JS file is only 2.7 MB big and generating it is a lot faster.

I tried to find out what exactly is the cause of this problem and got so far that just including this single line of code has the result of making the JS file bigger:

val instant = Instant.ofEpochMilli(0)

However, I can't see anything special in the implementation of this method.

I assume that it has something to do with Locales being included in the JS file, since I see many lines like this one in the large version of the generated output only:

var xs$53 = new $c_sjs_js_WrappedArray().init___sjs_js_Array([new $c_Llocales_cldr_CurrencyDisplayName().init___T__s_Option("Brazilian New Cruzado (1989\u20131990)", $m_s_None$()), new $c_Llocales_cldr_CurrencyDisplayName().init___T__s_Option("Brazilian new cruzado (1989\u20131990)", new $c_s_Some().init___O("one")), new $c_Llocales_cldr_CurrencyDisplayName().init___T__s_Option("Brazilian new cruzados (1989\u20131990)", new $c_s_Some().init___O("other"))]);
  var this$120 = $m_sci_List$();
  var cbf$53 = this$120.ReusableCBFInstance$2;
  var jsx$502 = new $c_Llocales_cldr_NumberCurrency().init___T__sc_Seq__sc_Seq("BRN", jsx$503, $as_sci_List($s_sc_TraversableLike$class__to__sc_TraversableLike__scg_CanBuildFrom__O(xs$53, cbf$53)));
  var jsx$501 = $m_sci_Nil$();
  $m_sci_List$();
  var xs$54 = new $c_sjs_js_WrappedArray().init___sjs_js_Array([new $c_Llocales_cldr_CurrencyDisplayName().init___T__s_Option("Brazilian Cruzeiro (1993\u20131994)", $m_s_None$()), new $c_Llocales_cldr_CurrencyDisplayName().init___T__s_Option("Brazilian cruzeiro (1993\u20131994)", new $c_s_Some().init___O("one")), new $c_Llocales_cldr_CurrencyDisplayName().init___T__s_Option("Brazilian cruzeiros (1993\u20131994)", new $c_s_Some().init___O("other"))]);
  var this$122 = $m_sci_List$();
  var cbf$54 = this$122.ReusableCBFInstance$2;
  var jsx$500 = new $c_Llocales_cldr_NumberCurrency().init___T__sc_Seq__sc_Seq("BRR", jsx$501, $as_sci_List($s_sc_TraversableLike$class__to__sc_TraversableLike__scg_CanBuildFrom__O(xs$54, cbf$54)));
  var jsx$499 = $m_sci_Nil$(); 

Linking error when using `Duration.compareTo`

Clone reproduction repository and run sbt fastOptJS.

Looks like it could be fixed with an explicit implementation of compareTo in Duration.

Instant has the same problem as well.

Error and stack trace:

[info] Fast optimizing scala-java-time-compareTo/target/scala-2.12/scala-java-time-compareto-fastopt.js
[error] Referring to non-existent method java.time.Duration.compareTo(java.time.Duration)scala.Int
[error]   called from Main$.main()scala.Unit
[error]   called from scala.scalajs.js.JSApp.$$js$exported$meth$main()java.lang.Object
[error]   called from Main$.$$js$exported$meth$main()java.lang.Object
[error]   called from Main$.main
[error]   exported to JavaScript with @JSExport
[error] involving instantiated classes:
[error]   Main$
java.lang.RuntimeException: There were linking errors
        at scala.sys.package$.error(package.scala:27)
        at org.scalajs.core.tools.linker.frontend.BaseLinker.linkInternal(BaseLinker.scala:133)
        at org.scalajs.core.tools.linker.frontend.BaseLinker.linkInternal(BaseLinker.scala:86)
        at org.scalajs.core.tools.linker.frontend.LinkerFrontend$$anonfun$4.apply(LinkerFrontend.scala:54)
        at org.scalajs.core.tools.linker.frontend.LinkerFrontend$$anonfun$4.apply(LinkerFrontend.scala:54)
        at org.scalajs.core.tools.logging.Logger$class.time(Logger.scala:28)
        at org.scalajs.sbtplugin.Loggers$SbtLoggerWrapper.time(Loggers.scala:7)
        at org.scalajs.core.tools.linker.frontend.LinkerFrontend.link(LinkerFrontend.scala:53)
        at org.scalajs.core.tools.linker.Linker$$anonfun$link$1.apply$mcV$sp(Linker.scala:50)
        at org.scalajs.core.tools.linker.Linker$$anonfun$link$1.apply(Linker.scala:49)
        at org.scalajs.core.tools.linker.Linker$$anonfun$link$1.apply(Linker.scala:49)
        at org.scalajs.core.tools.linker.Linker.guard(Linker.scala:67)
        at org.scalajs.core.tools.linker.Linker.link(Linker.scala:49)
        at org.scalajs.core.tools.linker.ClearableLinker$$anonfun$link$1.apply(ClearableLinker.scala:51)
        at org.scalajs.core.tools.linker.ClearableLinker$$anonfun$link$1.apply(ClearableLinker.scala:51)
        at org.scalajs.core.tools.linker.ClearableLinker.linkerOp(ClearableLinker.scala:62)
        at org.scalajs.core.tools.linker.ClearableLinker.link(ClearableLinker.scala:51)
        at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$org$scalajs$sbtplugin$ScalaJSPluginInternal$$scalaJSStageSettings$4$$anonfun$apply$6$$anonfun$apply$7.apply(ScalaJSPluginInternal.scala:251)
        at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$org$scalajs$sbtplugin$ScalaJSPluginInternal$$scalaJSStageSettings$4$$anonfun$apply$6$$anonfun$apply$7.apply(ScalaJSPluginInternal.scala:239)
        at sbt.FileFunction$$anonfun$cached$1.apply(Tracked.scala:253)
        at sbt.FileFunction$$anonfun$cached$1.apply(Tracked.scala:253)
        at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3$$anonfun$apply$4.apply(Tracked.scala:267)
        at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3$$anonfun$apply$4.apply(Tracked.scala:263)
        at sbt.Difference.apply(Tracked.scala:224)
        at sbt.Difference.apply(Tracked.scala:206)
        at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3.apply(Tracked.scala:263)
        at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3.apply(Tracked.scala:262)
        at sbt.Difference.apply(Tracked.scala:224)
        at sbt.Difference.apply(Tracked.scala:200)
        at sbt.FileFunction$$anonfun$cached$2.apply(Tracked.scala:262)
        at sbt.FileFunction$$anonfun$cached$2.apply(Tracked.scala:260)
        at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$org$scalajs$sbtplugin$ScalaJSPluginInternal$$scalaJSStageSettings$4$$anonfun$apply$6.apply(ScalaJSPluginInternal.scala:256)
        at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$org$scalajs$sbtplugin$ScalaJSPluginInternal$$scalaJSStageSettings$4$$anonfun$apply$6.apply(ScalaJSPluginInternal.scala:237)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
        at sbt.std.Transform$$anon$4.work(System.scala:63)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
        at sbt.Execute.work(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
[error] (compile:fastOptJS) There were linking errors

LocalDate.now fails if no tzdb in scala.js

LocalDate.now calls Clock.systemDefaultZone. On my machine, it finds that the timezone is Europe/Paris and I end up with an exception:

Uncaught java.time.zone.ZoneRulesException: Unknown time-zone ID: Europe/Paris
    at $p_Ljava_time_zone_ZoneRulesProvider$__getProvider__T__Ljava_time_zone_ZoneRulesProvider (http://localhost:8080/assets/main.js:9479:13)

I can solve it by using tzdb but this is an overkill when all I want is the current year, month and day.

Reduce file size for Scala.js

I am looking forward a way to get the benefits of java.time API and reduce the Scala.js-generated file size at same time. I have started evaluating sbt-tzdb v0.1 for that purpose.

I could save averagely 560KB in size (fullOptJS, no gzipped) in my several projects, by removing timezone DB with zonesFilter := { (z:String) => false}. That is 25%~40% savings for my projects.
(Note: I suppose my projects require no timezone DB, since my code base uses only OffsetDateTime, LocalDate and Duration right now)

I also investigated why some project can save 40%, but other can save only 25%. My observation shows that my projects can save additional 747KB averagely, if DateTimeFormatter usage is eliminated completely. I suppose that there are huge amounts of locales for DateTimeFormatter as similar as timezone DB.

So... it would be great if one can filter locales for DateTimeFormatter in common with timezone DB. (Sorry in advance, in case of my assumption regarding DateTimeFormatter is incorrect)

The below is my observation of file size reduction in my projects.

Project  Total (KB) Rest of code (KB) TimeZoneDB (KB) DateTimeFormatter (KB)
A 2465 1153 560 752
B 2286 978 560 748
C 2246 939 560 747
D 2237 930 560 747
E 2166 862 560 744
F 2140 835 560 745
G 2130 825 560 745
H 2113 808 560 745
I 2105 801 559 745
J 2083 779 559 745
K 1311 753 557 0
L 1307 749 557 0
M 1283 725 557 0
N 1271 713 557 0
  • Total = Rest of code + TimeZoneDB + DateTimeFormatter

The below chart illustrates the above table
image

ZoneId.systemDefault not working

I noticed that ZoneId.systemDefault is not working in javascript, in the jvm it is working fine. My current solution is converting using this:

ZoneId.ofOffset(
    Clock.systemDefaultZone.getZone.getId,
    ZoneOffset.ofTotalSeconds((new Date().getTimezoneOffset()) * -60)

Does it still need implementation?

documentation questions, regarding use on JVM, JS and Native

I was re-implementing a a.pure scala version of banana-rdf, which needs xsd dateTimestamps, and then I realised I need a pure Scala implementation for scalajs. and following links I found your project.

Your documentation states:

The scala-java-time library is currently available for Scala (JVM, version 8 and later) and Scala.js (JavaScript).

Once I noticed that you use the same java.time namespace I got a bit confused, because I wondered if one was meant to override the jvm package, and how one was meant to do that. But @sjrd mentioned that the primary use-case for this lib is not for the jvm... which makes sense, but the sentence above is a bit confusing.

So I guess this is primarily useful for scala-js and Scala-native, right? (Which is actually what I was looking for)

If so that could be made a bit clearer on the documentation page. Either that or one also needs some explanation of how one would make sure one was using your java.time or the JVM one...

Submit scala-java-time to SP (Scala Platform)

With the SP process being announced (https://contributors.scala-lang.org/) I believe that there is a good argument for including scala-java-time into the Scala Platform as it would provide us with an idiomatic cross platform time/date library (and scala-java-time being in the SP would also help drive its adoption). A huge amount of work by @soc was put into making this library, and it would be a shame to see the work go to waste or not live up to its potential.

For the time being, these are the following changes that I would see as needing to be done before we submit (if its chosen to do so)

  • Rename scala-java-time to something like scala-time, and put the library into a scala.time namespace
  • Integrate MIMA to ensure binary compatibility
  • Do any more changes to make the library more idiomatically Scala (if they exist) rather than being just a java.time clone
  • Resolve any big, outstanding bugs
  • Add in java converters to seamlessly go from scala.time types to java.time (and vice versa) to make it painless for end users

Prohibited package name: java.time

I'm using this package in project with Scala.js and JVM cross-compilation and it crashes doobie in runtime.

Here's exception I get:

java.lang.ExceptionInInitializerError
    at doobie.imports$.<init>(imports.scala:90)
    at doobie.imports$.<clinit>(imports.scala)
    at me.chuwy.doobietime.Main$.<init>(Main.scala:34)
    at me.chuwy.doobietime.Main$.<clinit>(Main.scala)
    at me.chuwy.doobietime.Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
    Caused by: java.lang.SecurityException: Prohibited package name: java.time
    at java.lang.ClassLoader.preDefineClass(ClassLoader.java:659)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at scala.reflect.runtime.JavaMirrors$JavaMirror.javaClass(JavaMirrors.scala:555)
    at scala.reflect.runtime.JavaMirrors$JavaMirror.tryJavaClass(JavaMirrors.scala:559)
    at scala.reflect.runtime.SymbolLoaders$PackageScope$$anonfun$lookupEntry$1.apply(SymbolLoaders.scala:137)
    at scala.reflect.runtime.SymbolLoaders$PackageScope$$anonfun$lookupEntry$1.apply(SymbolLoaders.scala:126)
    at scala.reflect.runtime.Gil$class.gilSynchronized(Gil.scala:19)
    at scala.reflect.runtime.JavaUniverse.gilSynchronized(JavaUniverse.scala:16)
    at scala.reflect.runtime.SymbolLoaders$PackageScope.syncLockSynchronized(SymbolLoaders.scala:124)
    at scala.reflect.runtime.SymbolLoaders$PackageScope.lookupEntry(SymbolLoaders.scala:126)
    at scala.reflect.internal.Types$Type.findDecl(Types.scala:971)
    at scala.reflect.internal.Types$Type.decl(Types.scala:566)
    at scala.reflect.internal.SymbolTable.openPackageModule(SymbolTable.scala:335)
    at scala.reflect.runtime.SymbolLoaders$LazyPackageType$$anonfun$complete$2.apply$mcV$sp(SymbolLoaders.scala:74)
    at scala.reflect.runtime.SymbolLoaders$LazyPackageType$$anonfun$complete$2.apply(SymbolLoaders.scala:71)
    at scala.reflect.runtime.SymbolLoaders$LazyPackageType$$anonfun$complete$2.apply(SymbolLoaders.scala:71)
    at scala.reflect.internal.SymbolTable.slowButSafeEnteringPhaseNotLaterThan(SymbolTable.scala:263)
    at scala.reflect.runtime.SymbolLoaders$LazyPackageType.complete(SymbolLoaders.scala:71)
    at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1514)
    at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$1.scala$reflect$runtime$SynchronizedSymbols$SynchronizedSymbol$$super$info(SynchronizedSymbols.scala:174)
    at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anonfun$info$1.apply(SynchronizedSymbols.scala:127)
    at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anonfun$info$1.apply(SynchronizedSymbols.scala:127)
    at scala.reflect.runtime.Gil$class.gilSynchronized(Gil.scala:19)
    at scala.reflect.runtime.JavaUniverse.gilSynchronized(JavaUniverse.scala:16)
    at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$class.gilSynchronizedIfNotThreadsafe(SynchronizedSymbols.scala:123)
    at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$1.gilSynchronizedIfNotThreadsafe(SynchronizedSymbols.scala:174)
    at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$class.info(SynchronizedSymbols.scala:127)
    at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$1.info(SynchronizedSymbols.scala:174)
    at scala.reflect.internal.Types$TypeRef.thisInfo(Types.scala:2194)
    at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:2199)
    at scala.reflect.internal.tpe.FindMembers$FindMemberBase.<init>(FindMembers.scala:17)
    at scala.reflect.internal.tpe.FindMembers$FindMember.<init>(FindMembers.scala:219)
    at scala.reflect.internal.Types$Type.scala$reflect$internal$Types$Type$$findMemberInternal$1(Types.scala:1014)
    at scala.reflect.internal.Types$Type.findMember(Types.scala:1016)
    at scala.reflect.internal.Types$Type.memberBasedOnName(Types.scala:631)
    at scala.reflect.internal.Types$Type.member(Types.scala:600)
    at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:48)
    at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
    at scala.reflect.internal.Mirrors$RootsBase.staticModuleOrClass(Mirrors.scala:77)
    at scala.reflect.internal.Mirrors$RootsBase.staticClass(Mirrors.scala:122)
    at scala.reflect.internal.Mirrors$RootsBase.staticClass(Mirrors.scala:22)
    at doobie.util.meta$MetaInstances$$typecreator7$1.apply(meta.scala:466)
    at scala.reflect.api.TypeTags$WeakTypeTagImpl.tpe$lzycompute(TypeTags.scala:232)
    at scala.reflect.api.TypeTags$WeakTypeTagImpl.tpe(TypeTags.scala:232)
    at doobie.util.meta$Meta$$anon$1.<init>(meta.scala:209)
    at doobie.util.meta$Meta$.basic(meta.scala:208)
    at doobie.util.meta$Meta$$anon$1.xmap(meta.scala:216)
    at doobie.util.meta$MetaInstances$class.$init$(meta.scala:466)
    at doobie.util.meta$Meta$.<init>(meta.scala:171)
    at doobie.util.meta$Meta$.<clinit>(meta.scala)
    at doobie.imports$.<init>(imports.scala:90)
    at doobie.imports$.<clinit>(imports.scala)
    at me.chuwy.doobietime.Main$.<init>(Main.scala:34)
    at me.chuwy.doobietime.Main$.<clinit>(Main.scala)
    at me.chuwy.doobietime.Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)

Project is pretty simple and I reproduced it without Scala.js and even without using any org.threeten classes.

import fs2._
import doobie.imports._

object Main extends App {
  val xa = DriverManagerTransactor[Task]("org.postgresql.Driver", "jdbc:postgresql:timefail", "timefail", "timefail")
  case class Item(title: String, createDate: java.sql.Timestamp)

  def insertItem(item: Item): Task[Int] = {
    val sql: Update0 = sql"INSERT INTO items (title, create_date) VALUES (${item.title}, ${item.createDate})".update
    sql.run.transact(xa)
  }

  insertItem(Item("Do somethin", new java.sql.Timestamp(144304323444L))).unsafeRun()
}

As soon as I add scala-java-time into dependencies it starts to crash.

Scala version is 2.12.1, JDK8, I tried it with scala-java-time M7 and M8.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.