Tag

simpledateformat

2 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 Architect Essentials
Java Architect Essentials
Sep 27, 2023 · Backend Development

Understanding the Difference Between yyyy and YYYY in Java Date Formatting

This article explains how using 'YYYY' instead of 'yyyy' in Java's SimpleDateFormat can cause year miscalculations, especially around year-end weeks, demonstrates the issue with sample code, shows correct usage, and warns developers to avoid this subtle bug.

JavaYearbackend development
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 31, 2023 · Backend Development

How to Solve SimpleDateFormat Thread Safety Issues in High-Concurrency Scenarios

This article presents several common solutions for addressing the thread‑safety problem of Java's SimpleDateFormat in high‑concurrency environments, including using local variables, synchronized blocks, Lock, ThreadLocal, Java 8 DateTimeFormatter, and Joda‑Time, and evaluates their performance and suitability.

DateTimeFormatterJavaThread Safety
0 likes · 17 min read
How to Solve SimpleDateFormat Thread Safety Issues in High-Concurrency Scenarios
360 Quality & Efficiency
360 Quality & Efficiency
May 19, 2023 · Backend Development

Resolving SimpleDateFormat Thread Safety Issues with ThreadLocal in Java

This article explains why Java's SimpleDateFormat is not thread‑safe, demonstrates the concurrency problem with a multithreaded demo, and presents three solutions—creating new instances, synchronizing access, and using ThreadLocal—highlighting the ThreadLocal approach with code examples and discussion of potential memory‑leak considerations.

JavaThread Safetyconcurrency
0 likes · 4 min read
Resolving SimpleDateFormat Thread Safety Issues with ThreadLocal in Java
Selected Java Interview Questions
Selected Java Interview Questions
Sep 7, 2022 · Backend Development

Java Date and Time Formatting: Methods, Thread Safety, and Best Practices

This article compares three common Java date‑time formatting approaches—SimpleDateFormat, Java 8’s DateTimeFormatter, and Apache Commons Lang3’s DateFormatUtils—examines thread‑safety issues, provides code examples, and offers conversion utilities between Date, LocalDate, and LocalDateTime for robust backend development.

Apache CommonsDateTimeDateTimeFormatter
0 likes · 9 min read
Java Date and Time Formatting: Methods, Thread Safety, and Best Practices
Java Architect Essentials
Java Architect Essentials
Jul 3, 2022 · Backend Development

Thread Safety Issues of SimpleDateFormat.parse() and format() Methods and Their Solutions

This article explains why SimpleDateFormat.parse() and SimpleDateFormat.format() are not thread‑safe in Java, analyzes the underlying causes involving shared Calendar objects, and presents three practical solutions—including per‑thread instances, synchronized blocks, and ThreadLocal usage—to eliminate concurrency bugs.

Date ParsingJavaSynchronization
0 likes · 11 min read
Thread Safety Issues of SimpleDateFormat.parse() and format() Methods and Their Solutions
Java Architect Essentials
Java Architect Essentials
Jan 11, 2022 · Backend Development

Understanding the Difference Between yyyy and YYYY in Java Date Formatting

This article explains the subtle difference between 'yyyy' and 'YYYY' in Java's SimpleDateFormat, demonstrates how using the wrong pattern can cause year miscalculations—especially on December 31st—and provides code examples and a clear explanation to help developers avoid this common bug.

Javabackendbug
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
Full-Stack Internet Architecture
Full-Stack Internet Architecture
May 18, 2021 · Backend Development

Understanding Thread Safety Issues with SimpleDateFormat and Solutions in Java

This article explains why SimpleDateFormat is not thread‑safe in Java, demonstrates the problem with multithreaded examples, and presents five practical solutions—including local variables, synchronized blocks, explicit locks, ThreadLocal, and the modern DateTimeFormatter—along with their advantages and drawbacks.

DateTimeFormatterJavaThread Safety
0 likes · 13 min read
Understanding Thread Safety Issues with SimpleDateFormat and Solutions in Java
Selected Java Interview Questions
Selected Java Interview Questions
Aug 27, 2020 · Backend Development

Thread Safety of SimpleDateFormat and How to Solve It with ThreadLocal

This article explains why a static SimpleDateFormat instance is not thread‑safe, demonstrates the issue with concurrent parsing, and provides a ThreadLocal‑based solution with complete Java code examples and performance observations.

JavaThread Safetyconcurrency
0 likes · 10 min read
Thread Safety of SimpleDateFormat and How to Solve It with ThreadLocal
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
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Feb 3, 2020 · Fundamentals

Understanding SimpleDateFormat, Week Year, and ISO 8601 in Java

This article explains how to use Java's SimpleDateFormat for date‑time formatting and parsing, describes the pattern letters, clarifies the difference between "yyyy" and "YYYY" for week‑year calculations, and shows how ISO 8601 week definitions are supported in Java with practical code examples.

JavaJava8date formatting
0 likes · 8 min read
Understanding SimpleDateFormat, Week Year, and ISO 8601 in Java
Java Architecture Diary
Java Architecture Diary
Nov 2, 2019 · Backend Development

Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It Efficiently

This article explains why Java's SimpleDateFormat is not thread‑safe, demonstrates the resulting concurrency errors, and presents four practical solutions—including per‑call instantiation, ThreadLocal, Apache FastDateFormat, and Java 8's Instant with DateTimeFormatter—along with JMH benchmark results comparing their performance across JDK 8 and JDK 11.

Thread Safetydateformatperformance
0 likes · 7 min read
Why SimpleDateFormat Is Not Thread‑Safe and How to Fix It Efficiently
Beike Product & Technology
Beike Product & Technology
Mar 16, 2018 · Backend Development

Investigating a Java Heap Memory Issue: A Detective Story of Debugging and Root Cause Analysis

This article narrates a step‑by‑step investigation of a Java server whose heap memory exceeded 95%, detailing log collection, tool usage, thread analysis, and ultimately uncovering a thread‑unsafe SimpleDateFormat that caused an infinite loop and massive memory consumption.

JavaThread Safetydebugging
0 likes · 15 min read
Investigating a Java Heap Memory Issue: A Detective Story of Debugging and Root Cause Analysis
Qunar Tech Salon
Qunar Tech Salon
Mar 13, 2016 · Fundamentals

Understanding java.util.Date, Calendar, and SimpleDateFormat in Java

This article explains the legacy java.util.Date class, its limited useful constructors and methods, the more flexible java.util.Calendar API, how to format and parse dates with DateFormat and SimpleDateFormat, and best practices for storing timestamps in databases using long values.

DatabaseDateJava
0 likes · 9 min read
Understanding java.util.Date, Calendar, and SimpleDateFormat in Java