src/main/java/com/rockagen/commons/util/JsonUtil.java
private static ObjectMapper initMapper() {

		ObjectMapper mapper = new ObjectMapper();
		// to enable standard indentation ("pretty-printing"):
		mapper.enable(SerializationFeature.INDENT_OUTPUT);
		// to allow serialization of "empty" POJOs (no properties to serialize)
		// (without this setting, an exception is thrown in those cases)
		mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
		// set writer flush after writer value
		mapper.enable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
		// ObjectMapper will call close() and root values that implement
		// java.io.Closeable;
		// including cases where exception is thrown and serialization does not
		// completely succeed.
		mapper.enable(SerializationFeature.CLOSE_CLOSEABLE);
		// to write java.util.Date, Calendar as number (timestamp):
		mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
		// disable default date to timestamp
		mapper.disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS);

		// DeserializationFeature for changing how JSON is read as POJOs:

		// to prevent exception when encountering unknown property:
		mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
		// disable default date to timestamp
		mapper.disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS);
		// to allow coercion of JSON empty String ("") to null Object value:
		mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		// Set Default date fromat
		mapper.setDateFormat(df);

		return mapper;

	}
private static ObjectMapper initMapper() {

		ObjectMapper mapper = new ObjectMapper();
		// to enable standard indentation ("pretty-printing"):
		mapper.enable(SerializationFeature.INDENT_OUTPUT);
		// to allow serialization of "empty" POJOs (no properties to serialize)
		// (without this setting, an exception is thrown in those cases)
		mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
		// set writer flush after writer value
		mapper.enable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
		// ObjectMapper will call close() and root values that implement
		// java.io.Closeable;
		// including cases where exception is thrown and serialization does not
		// completely succeed.
		mapper.enable(SerializationFeature.CLOSE_CLOSEABLE);
		// to write java.util.Date, Calendar as number (timestamp):
		mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
		// disable default date to timestamp
		mapper.disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS);

		// DeserializationFeature for changing how JSON is read as POJOs:

		// to prevent exception when encountering unknown property:
		mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
		// disable default date to timestamp
		mapper.disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS);
		// to allow coercion of JSON empty String ("") to null Object value:
		mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		// Set Default date fromat
		mapper.setDateFormat(df);

		return mapper;

	}
Initialize mapper

@return initialized {@link ObjectMapper}