Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed date parsing because Java's SimpleDateFormat is not thread-safe
  • Loading branch information
JanHolger committed Feb 14, 2022
commit ff8e5eca1cc777ac9fafca05ad49c7017820197b
10 changes: 3 additions & 7 deletions src/main/java/org/javawebstack/abstractdata/mapper/Mapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class Mapper {

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

public Mapper dateFormat(String format) {
return dateFormat(new SimpleDateFormat(format));
}

public Mapper dateFormat(DateFormat dateFormat) {
this.dateFormat = dateFormat;
this.dateFormat = format;
return this;
}

public DateFormat getDateFormat() {
return dateFormat;
return new SimpleDateFormat(dateFormat);
}

public boolean shouldOmitNull() {
Expand Down