Skip to content

Commit ff8e5ec

Browse files
committed
Fixed date parsing because Java's SimpleDateFormat is not thread-safe
1 parent 44628e7 commit ff8e5ec

File tree

1 file changed

+3
-7
lines changed
  • src/main/java/org/javawebstack/abstractdata/mapper

1 file changed

+3
-7
lines changed

src/main/java/org/javawebstack/abstractdata/mapper/Mapper.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public class Mapper {
1818

19-
private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
19+
private String dateFormat = "yyyy-MM-dd HH:mm:ss";
2020
private NamingPolicy namingPolicy = NamingPolicy.NONE;
2121
private boolean exposeRequired;
2222
private boolean omitNull = true;
@@ -62,16 +62,12 @@ public AbstractElement map(MapperContext context, Object obj) throws MapperExcep
6262
}
6363

6464
public Mapper dateFormat(String format) {
65-
return dateFormat(new SimpleDateFormat(format));
66-
}
67-
68-
public Mapper dateFormat(DateFormat dateFormat) {
69-
this.dateFormat = dateFormat;
65+
this.dateFormat = format;
7066
return this;
7167
}
7268

7369
public DateFormat getDateFormat() {
74-
return dateFormat;
70+
return new SimpleDateFormat(dateFormat);
7571
}
7672

7773
public boolean shouldOmitNull() {

0 commit comments

Comments
 (0)