Case-sensitive
Uppercase YYYY
means year of a week-based year rather than a calendar year (lowercase yyyy
).
So you are seeing a feature, not a bug. The second to the last day of 2018 is in the first week of 2019 according to the definition of a week used by SimpleDateFormat
. That definition varies by Locale
.
Avoid legacy date-time classes
You are using terrible date-time classes that were supplanted years ago by the modern java.time classes defined in JSR 310.
LocalDate
The LocalDate
class is appropriate to your string inputs.
String input = "2019-12-30" ;
LocalDate ld = LocalDate.parse( input ) ;