Get the latest tech news

Java's SimpleDateFormat: YYYY vs. Yyyy


This post would have been more appropriate a week ago when 2018 was coming to a close but better late than never. This is a friendly reminder that when formatting dates in Java’s SimpleDateFormat class there is a subtle difference between YYYY and yyyy.

This post would have been more appropriate a week ago when 2018 was coming to a close but better late than never. The first and last make sense since the two year formats match. In general, you should almost always use yyyy so it’s a good tactic to add some form of linting or checking to make sure your code does not have any date formats referencing YYYY.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Java

Java

Photo of Yyyy

Yyyy

Photo of SimpleDateFormat

SimpleDateFormat

Related news:

News photo

How Java's Executable Assembly Jars Work

News photo

So you want to write Java in Neovim

News photo

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM