Package com.alibaba.fastjson.serializer

Examples of com.alibaba.fastjson.serializer.SimpleDateFormatSerializer


import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;

public class DateFieldTest7 extends TestCase {
  public void test_0() throws Exception {
    SerializeConfig config = new SerializeConfig();
    config.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
    config.setAsmEnable(false);

    Entity object = new Entity();
    object.setValue(new Date());
    String text = JSON.toJSONString(object, config);
View Full Code Here


import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;

public class DateFieldTest6 extends TestCase {
  public void test_0() throws Exception {
    SerializeConfig mapping = new SerializeConfig();
    mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));

    Entity object = new Entity();
    object.setValue(new Date());
    String text = JSON.toJSONString(object, mapping);
    Assert.assertEquals("{\"value\":\"" + new SimpleDateFormat("yyyy-MM-dd").format(object.getValue()) + "\"}", text);
View Full Code Here

public class DateFieldTest3 extends TestCase {

    public void test_codec() throws Exception {
        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));

        V0 v = new V0();
        v.setValue(new Date());

        String text = JSON.toJSONString(v, mapping);
View Full Code Here

    public void test_codec_no_asm() throws Exception {
        V0 v = new V0();
        v.setValue(new Date());

        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
        mapping.setAsmEnable(false);

        String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"value\":" + JSON.toJSONString(new SimpleDateFormat("yyyy-MM-dd").format(v.getValue())) + "}", text);
    }
View Full Code Here

    public void test_codec_asm() throws Exception {
        V0 v = new V0();
        v.setValue(new Date());
       
        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
        mapping.setAsmEnable(true);
       
        String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"value\":" + JSON.toJSONString(new SimpleDateFormat("yyyy-MM-dd").format(v.getValue())) + "}", text);
    }
View Full Code Here

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(true);

        String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
        Assert.assertEquals("{\"value\":null}", text);

        V0 v1 = JSON.parseObject(text, V0.class);

        Assert.assertEquals(v1.getValue(), v.getValue());
View Full Code Here

   
    public void test_codec_null_no_asm() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
        mapping.setAsmEnable(false);

        String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"value\":null}", text);
View Full Code Here

public class DateFieldTest3 extends TestCase {

    public void test_codec() throws Exception {
        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));

        V0 v = new V0();
        v.setValue(new Date());

        String text = JSON.toJSONString(v, mapping);
View Full Code Here

    public void test_codec_no_asm() throws Exception {
        V0 v = new V0();
        v.setValue(new Date());

        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
        mapping.setAsmEnable(false);

        String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"value\":" + JSON.toJSONString(new SimpleDateFormat("yyyy-MM-dd").format(v.getValue())) + "}", text);
    }
View Full Code Here

    public void test_codec_asm() throws Exception {
        V0 v = new V0();
        v.setValue(new Date());
       
        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
        mapping.setAsmEnable(true);
       
        String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"value\":" + JSON.toJSONString(new SimpleDateFormat("yyyy-MM-dd").format(v.getValue())) + "}", text);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.serializer.SimpleDateFormatSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.