Why is Java's SimpleDateFormat not thread
This question already has an answer here:
SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner.
From the JavaDoc ,
But Date formats are not synchronized . It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally .
To make the SimpleDateFormat class thread-safe, look at the following approaches :
Java 8中的DateTimeFormatter是SimpleDateFormat不可变且线程安全的替代方案。
