tl;dr
LocalDate.of( 2020, Month.DECEMBER, 1 )
Avoid legacy date-time classes
You are using a terrible date-time class, Date
, which has many tragic design flaws. One of those flaws is an offset of 1900 years.
The solution is simple: Stop using that class. It is now legacy, supplanted years ago by the modern java.time classes defined in JSR 310.
Plus, the java.util.Date
class does not fit your need. That class represents a moment, a date with time of day as seen in UTC, an offset of zero hours minutes seconds. But you want a date-only, without time of day, without the context of an offset or time zone.
The other Date
,java.sql.Date
class, pretends to fit your need as a date-only value. But actually that class inherited from java.util.Date
in an extremely poor design choice.
Use LocalDate
Instead, use java.time.LocalDate
.
This class uses sane numbering:
- The year 2020 is 2020.
- The months January through December are 1 to 12.
Instantiate via static
factory methods.
LocalDate ld = LocalDate.of( 2020, 12, 1 ) ;
Or use the Month
enum.
LocalDate ld = LocalDate.of( 2020, Month.DECEMBER, 1 ) ;
Interrogate for parts.
int y = ld.getYear() ;
int m = ld.getMonthValue() ;
String month = ld.etMonth().getDisplayName( TextStyle.FULL , Locale.CANADA_FRENCH ) ;
int d = ld.getDayOfMonth() ;
String dow = ld.getDayOfWeek().getDisplayName( TextStyle.FULL , Locale.JAPAN ) ;