Tag

yyyy vs YYYY

0 views collected around this technical thread.

Java Tech Enthusiast
Java Tech Enthusiast
Jan 3, 2025 · Fundamentals

Understanding the Difference Between yyyy and YYYY in Java SimpleDateFormat

The article explains that in Java's SimpleDateFormat the lowercase y pattern (year‑of‑era) should be used for calendar dates, because the uppercase Y pattern represents a week‑based year which can incorrectly roll over to the next year near year‑end, causing bugs.

Javabugdateformat
0 likes · 4 min read
Understanding the Difference Between yyyy and YYYY in Java SimpleDateFormat
Java Captain
Java Captain
Mar 2, 2022 · Backend Development

Understanding the Difference Between yyyy and YYYY in Java Date Formatting

This article explains how using the uppercase YYYY pattern in Java's SimpleDateFormat can incorrectly shift dates to the next year for week‑based years, demonstrates the issue with sample code, and provides guidance to avoid this subtle bug in date handling.

Backend DevelopmentJavabug prevention
0 likes · 4 min read
Understanding the Difference Between yyyy and YYYY in Java Date Formatting
Selected Java Interview Questions
Selected Java Interview Questions
Dec 31, 2021 · Backend Development

Understanding the Difference Between yyyy and YYYY in Java Date Formatting

The article explains how using the week‑based year pattern (YYYY) instead of the calendar year pattern (yyyy) in Java's SimpleDateFormat can cause dates like 2019‑12‑31 to be displayed as 2020‑12‑31, illustrating the issue with code examples and a clear explanation of the underlying rules.

Javabackendcalendar
0 likes · 4 min read
Understanding the Difference Between yyyy and YYYY in Java Date Formatting
Selected Java Interview Questions
Selected Java Interview Questions
Aug 23, 2020 · Backend Development

Understanding the Difference Between yyyy and YYYY, and dd and DD in Java Date Formatting

This article explains how using uppercase YYYY and DD in Java date patterns produces week‑based year and day‑of‑year values, leading to unexpected results around year boundaries, and provides code examples and best‑practice recommendations to avoid these formatting bugs.

DateTimeFormatterJavadate formatting
0 likes · 7 min read
Understanding the Difference Between yyyy and YYYY, and dd and DD in Java Date Formatting