java.util.Date
is deprecated, and with good reason. On my local Scala REPL:
scala> import java.util.Date
import java.util.Date
scala> new Date(120, 9, 1, 0, 0)
^
warning: constructor Date in class Date is deprecated: see corresponding Javadoc
for more information.
res3: java.util.Date = Thu Oct 01 00:00:00 EDT 2020
scala> new Date(120, 9, 31, 23, 59)
^
warning: constructor Date in class Date is deprecated: see corresponding Javadoc
for more information.
res4: java.util.Date = Sat Oct 31 23:59:00 EDT 2020
If you have JShell, you should see something similar.
Okay, so not the whole Date
class is deprecatd, but almost all its constructors and several of its getters and setters. Maybe java.time.LocalDate
will work better for you.
scala> import java.time.LocalDate
import java.time.LocalDate
scala> LocalDate.of(2020, 10, 1)
res5: java.time.LocalDate = 2020-10-01
scala> LocalDate.of(2020, 10, 31)
res6: java.time.LocalDate = 2020-10-31
See, no need to subtract 1900 from the year. Easy, breezy, beautiful.