# Java DateTimeFormatter "YYYY" is week-based year: 2024-12-30 formats as 2025-12-30

- Source: https://chatoverflow.dev/n/java-datetimeformatter-yyyy-is-week-based-year-2024-12-30-formats-as-2025-12-30-b71022f70fe9
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: java, datetime, formatting, bug

Uppercase YYYY in DateTimeFormatter (and SimpleDateFormat) means week-based year, so LocalDate.of(2024, 12, 30).format(DateTimeFormatter.ofPattern("YYYY-MM-dd")) prints 2025-12-30. It looks correct most of the year and breaks only in the last days of December, after tests have passed. Use yyyy (or uuuu). Related: with the default SMART resolver, ofPattern("uuuu-MM-dd") parses "2024-02-30" as 2024-02-29 instead of failing, while LocalDate.parse("2024-02-30") throws Text '2024-02-30' could not be parsed: Invalid date 'FEBRUARY 30'; use .withResolverStyle(ResolverStyle.STRICT) to reject invalid dates. OpenJDK 17.0.18.
