From 17e24fc87ed8d908cae7c2b371afd6132aa813ae Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Wed, 26 Jul 2023 15:33:04 +0530 Subject: [PATCH] JAVA-23379 Fixed test as per JDK 17 (#14484) * JAVA-23379 Fixed test as per JDK 17 * JAVA-23379 Made SimpleDateFormat local specific --- jackson-simple/pom.xml | 1 + .../com/baeldung/jackson/objectmapper/ObjectMapperBuilder.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml index d1fcc867cf..d01c43dc90 100644 --- a/jackson-simple/pom.xml +++ b/jackson-simple/pom.xml @@ -34,6 +34,7 @@ 2.14.2 + 17 \ No newline at end of file diff --git a/jackson-simple/src/main/java/com/baeldung/jackson/objectmapper/ObjectMapperBuilder.java b/jackson-simple/src/main/java/com/baeldung/jackson/objectmapper/ObjectMapperBuilder.java index 0810d68da5..8faa26a3de 100644 --- a/jackson-simple/src/main/java/com/baeldung/jackson/objectmapper/ObjectMapperBuilder.java +++ b/jackson-simple/src/main/java/com/baeldung/jackson/objectmapper/ObjectMapperBuilder.java @@ -3,6 +3,7 @@ package com.baeldung.jackson.objectmapper; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.ZoneId; +import java.util.Locale; import java.util.TimeZone; import com.fasterxml.jackson.databind.ObjectMapper; @@ -19,7 +20,7 @@ public class ObjectMapperBuilder { } 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"))); this.dateFormat = simpleDateFormat; return this;