Last active
November 24, 2016 12:59
-
-
Save ghusta/6a160e0ae6e0e57a7061960f65fdc438 to your computer and use it in GitHub Desktop.
SimpleDateFormat is not thread-safe, so give one to each thread [Java]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SimpleDateFormat is not thread-safe, so give one to each thread | |
private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT_ISO_DATE = new ThreadLocal<SimpleDateFormat>() { | |
@Override | |
protected SimpleDateFormat initialValue() { | |
return new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$ | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then access by :
DATE_FORMAT_ISO_DATE.get()