Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix CustomDateDeserializer not working if system default language is … #42

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</developers>

<properties>
<postmark.version>1.8.0</postmark.version>
<postmark.version>1.8.1-SNAPSHOT</postmark.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<jackson.minimum.version>2.9.7</jackson.minimum.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;

/**
* In some of the responses from Postmark API, date format is not detected correctly by Jackson.
Expand All @@ -27,6 +28,8 @@ public class CustomDateDeserializer extends StdDeserializer<Date> {
"yyyy-MM-dd"
};

private static final Locale DATE_LOCALE = Locale.ENGLISH;


public CustomDateDeserializer() {
this(null);
Expand All @@ -43,7 +46,7 @@ public Date deserialize(JsonParser jsonParser, DeserializationContext ctxt) thro

for (String DATE_FORMAT : DATE_FORMATS) {
try {
return new SimpleDateFormat(DATE_FORMAT).parse(date);
return new SimpleDateFormat(DATE_FORMAT, DATE_LOCALE).parse(date);
} catch (ParseException e) { }
}

Expand Down