Package com.alibaba.fastjson.serializer

Examples of com.alibaba.fastjson.serializer.SimpleDateFormatSerializer


        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

        userLog.setUser(user);
        user.getUserLogs().add(userLog);

        SerializeConfig mapping = new SerializeConfig();

        mapping.put(java.sql.Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
        mapping.put(java.sql.Timestamp.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
        // mapping.put(User.class, new JavaBeanSerializer(User.class,
        // Collections.singletonMap("id", "uid")));

        JSONObject jsonObject = (JSONObject) JSON.toJSON(user);
        jsonObject.put("ext", "新加的属性");
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

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

  /**
   * Construct a new {@code JacksonJsonView}, setting the content type to {@code application/json}.
   */
  public MappingFastJsonView() {
    serializeConfig = new SerializeConfig();
    serializeConfig.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
    serializeConfig.put(java.sql.Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
    serializeConfig.put(java.sql.Timestamp.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
   
    setContentType(DEFAULT_CONTENT_TYPE);
  }
View Full Code Here

   */
  public MappingFastJsonHttpMessageConverter() {
    super(new MediaType("application", "json", DEFAULT_CHARSET));
   
    serializeConfig = new SerializeConfig();
    serializeConfig.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
    serializeConfig.put(java.sql.Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
    serializeConfig.put(java.sql.Timestamp.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
  }
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.