Added date serialization specification

This commit is contained in:
Luca Frosini 2022-06-13 10:21:21 +02:00
parent 7f964ad5d2
commit 2eb8bbb0b9
1 changed files with 7 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.Reader; import java.io.Reader;
import java.io.Writer; import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -58,6 +59,12 @@ public abstract class ElementMapper {
mapper = new ObjectMapper(); mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
/*
* Instructing Jackson to serialize any Date in the defined pattern
*/
SimpleDateFormat sdf = new SimpleDateFormat(Element.DATETIME_PATTERN);
mapper.setDateFormat(sdf);
knownTypes = new HashMap<>(); knownTypes = new HashMap<>();
List<Package> packages = new ArrayList<Package>(); List<Package> packages = new ArrayList<Package>();