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>
<jackson.version>2.14.2</jackson.version>
<java.version>17</java.version>
</properties>
</project>

View File

@ -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;