Synchronization
Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concur
That's true. You can find already questions concerning this issue on StackOverflow. I use to declare it as ThreadLocal:
private static final ThreadLocal THREAD_LOCAL_DATEFORMAT = new ThreadLocal() {
protected DateFormat initialValue() {
return new SimpleDateFormat("yyyyMMdd");
}
};
and in the code:
DateFormat df = THREAD_LOCAL_DATEFORMAT.get();