Instead of writing the following safe method, different from a stream.
private static final Calendar calendar = Calendar.getInstance(); public void fun() {
I am changing it to a safe version.
public void fun() { final Calendar calendar = Calendar.getInstance();
Instead of creating a new instance every time even for one thread, I made an improvement
public void fun() { final Calendar calendar = getCalendar();
For my third approach, is there a need to call ThreadLocal.remove ?
source share