Commit d0d4491817b39f5c17cd5d817975afe39fbb09f3
1 parent
27922d87e7
Exists in
master
and in
6 other branches
update code
Showing 1 changed file with 19 additions and 17 deletions
platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/DateUtils.java
View file @
d0d4491
... | ... | @@ -68,31 +68,33 @@ |
68 | 68 | */ |
69 | 69 | private static SimpleDateFormat getDateFormat(final String dateFormat) |
70 | 70 | { |
71 | - try { | |
71 | + | |
72 | 72 | ThreadLocal<SimpleDateFormat> tl = formatMap.get(dateFormat); |
73 | 73 | if (tl == null) |
74 | 74 | { |
75 | - lock.lock(); | |
76 | - tl = formatMap.get(dateFormat); | |
77 | - if (tl == null) | |
78 | - { | |
79 | - tl = new ThreadLocal<SimpleDateFormat>() | |
75 | + try { | |
76 | + lock.lock(); | |
77 | + tl = formatMap.get(dateFormat); | |
78 | + if (tl == null) | |
80 | 79 | { |
81 | - @Override | |
82 | - protected SimpleDateFormat initialValue() | |
80 | + tl = new ThreadLocal<SimpleDateFormat>() | |
83 | 81 | { |
84 | - return new SimpleDateFormat(dateFormat); | |
85 | - } | |
86 | - }; | |
87 | - formatMap.put(dateFormat, tl); | |
82 | + @Override | |
83 | + protected SimpleDateFormat initialValue() | |
84 | + { | |
85 | + return new SimpleDateFormat(dateFormat); | |
86 | + } | |
87 | + }; | |
88 | + formatMap.put(dateFormat, tl); | |
89 | + } | |
88 | 90 | } |
91 | + finally | |
92 | + { | |
93 | + lock.unlock(); | |
94 | + } | |
89 | 95 | } |
90 | 96 | return tl.get(); |
91 | - } | |
92 | - finally | |
93 | - { | |
94 | - lock.unlock(); | |
95 | - } | |
97 | + | |
96 | 98 | |
97 | 99 | } |
98 | 100 |