Example usage for com.fasterxml.jackson.databind ObjectMapper getSerializerProvider

List of usage examples for com.fasterxml.jackson.databind ObjectMapper getSerializerProvider

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind ObjectMapper getSerializerProvider.

Prototype

public SerializerProvider getSerializerProvider() 

Source Link

Usage

From source file:ren.hankai.cordwood.jackson.DateTimeSerializerTest.java

@Test
public void testSerializeWithCustomFormat() throws Exception {
    final ObjectMapper om = new ObjectMapper();
    final StringWriter sw = new StringWriter();
    final JsonGenerator jgen = om.getFactory().createGenerator(sw);

    final Date date = DateUtils.parseDate("2018-11-12 11:11:11", "yyyy-MM-dd HH:mm:ss");
    final DateTimeSerializer ser = new DateTimeSerializer("yyyy|MM|dd HH|mm|ss");
    ser.serialize(date, jgen, om.getSerializerProvider());
    jgen.flush();//  w  w  w. ja  v  a  2  s.  com

    Assert.assertEquals("\"2018|11|12 11|11|11\"", sw.toString());
}