JAVA-23379 Fixed test as per JDK 17 (#14484)

* JAVA-23379 Fixed test as per JDK 17

* JAVA-23379 Made SimpleDateFormat local specific
This commit is contained in:
Dhawal Kapil 2023-07-26 15:33:04 +05:30 committed by GitHub
parent 33a6f4610b
commit 17e24fc87e
2 changed files with 3 additions and 1 deletions

View File

@ -34,6 +34,7 @@
<properties> <properties>
<jackson.version>2.14.2</jackson.version> <jackson.version>2.14.2</jackson.version>
<java.version>17</java.version>
</properties> </properties>
</project> </project>

View File

@ -3,6 +3,7 @@ package com.baeldung.jackson.objectmapper;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -19,7 +20,7 @@ public class ObjectMapperBuilder {
} }
public ObjectMapperBuilder dateFormat() { public ObjectMapperBuilder dateFormat() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm a z"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm a z", Locale.ENGLISH);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone(ZoneId.of("Asia/Kolkata"))); simpleDateFormat.setTimeZone(TimeZone.getTimeZone(ZoneId.of("Asia/Kolkata")));
this.dateFormat = simpleDateFormat; this.dateFormat = simpleDateFormat;
return this; return this;