I recently came across an interesting piece of code at work:
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
What struck me as odd was the private
qualifier and that the fact that SimpleDateFormat
is not thread-safe. Is the private
some
odd attempt to work around concurrency issues, or was thread safety just overlooked? That led me to this question: Is a private static
still one instance per JVM, or does the private
actually change anything? My understanding was that this was a bug, but I thought I’d
write a test just to make sure.