Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Exception when converting a January LocalDate to Joda DateTime #7

Open
dlin303 opened this issue Dec 15, 2016 · 1 comment
Open

Exception when converting a January LocalDate to Joda DateTime #7

dlin303 opened this issue Dec 15, 2016 · 1 comment

Comments

@dlin303
Copy link

dlin303 commented Dec 15, 2016

repro (ignore the deprecated warnings):

scala> val d2 = new Date(2017,0,1)
<console>:12: warning: constructor Date in class Date is deprecated: see corresponding Javadoc for more information.
       val d2 = new Date(2017,0,1)
                ^
d2: java.util.Date = Mon Jan 01 00:00:00 EST 3917

scala> import com.meetup.timeywimey.JodaConverterImplicits._
import com.meetup.timeywimey.JodaConverterImplicits._

scala> import com.meetup.timeywimey.LegacyConverterImplicits._
import com.meetup.timeywimey.LegacyConverterImplicits._

scala> d2.toLocalDate.plusDays(4).asJoda.toDate
java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0
  at java.time.temporal.ValueRange.checkValidValue(ValueRange.java:311)
  at java.time.temporal.ChronoField.checkValidValue(ChronoField.java:703)
  at java.time.LocalDate.of(LocalDate.java:267)
  at com.meetup.timeywimey.LegacyConverters.toLocalDate(LegacyConverters.java:66)
  at com.meetup.timeywimey.LegacyConverterImplicits$DateToJava8.toLocalDate(LegacyConverterImplicits.scala:36)
  ... 43 elided

scala> 
@mbbush
Copy link

mbbush commented Oct 1, 2018

It looks like this was fixed in #6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants