Merge pull request #1200 from paopaofish/master

Using non-final variables to lock can cause thread-safety problems.Ac…
This commit is contained in:
许雪里 2019-10-25 10:54:24 +08:00 committed by GitHub
commit 08f6177d41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -24,7 +24,7 @@ public class DateUtil {
private static final String DATE_FORMAT = "yyyy-MM-dd"; private static final String DATE_FORMAT = "yyyy-MM-dd";
private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
private static ThreadLocal<Map<String, DateFormat>> dateFormatThreadLocal = new ThreadLocal<Map<String, DateFormat>>(); private static final ThreadLocal<Map<String, DateFormat>> dateFormatThreadLocal = new ThreadLocal<Map<String, DateFormat>>();
private static DateFormat getDateFormat(String pattern) { private static DateFormat getDateFormat(String pattern) {
if (pattern==null || pattern.trim().length()==0) { if (pattern==null || pattern.trim().length()==0) {
throw new IllegalArgumentException("pattern cannot be empty."); throw new IllegalArgumentException("pattern cannot be empty.");