DecimalFormat not thread safe in DateComponents, TimeComponents
Currently DateComponents
and TimeComponents
have static DecimalFormat
fields that are shared between threads to implement toString()
. According to the doc for DecimalFormat
"Decimal formats are generally 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."
I haven't seen any practical impacts and the actual implementation may be thread safe in particular JVMs, but for safety we should use these classes inline with their documentation.