Search in sources :

Example 6 with SerializerFeature

use of com.alibaba.fastjson.serializer.SerializerFeature in project fastjson by alibaba.

the class EnumTest2 method test_enum.

public void test_enum() throws Exception {
    Date date = new Date(1308841916550L);
    // 1308841916550
    Assert.assertEquals("1308841916550", JSON.toJSONString(date));
    // "2011-06-23T23:11:56.550"
    System.out.println(JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat));
    SerializerFeature[] features = { SerializerFeature.UseISO8601DateFormat, SerializerFeature.UseSingleQuotes };
    // '2011-06-23T23:11:56.550'
    System.out.println(JSON.toJSONString(date, features));
}
Also used : SerializerFeature(com.alibaba.fastjson.serializer.SerializerFeature) Date(java.util.Date)

Aggregations

SerializerFeature (com.alibaba.fastjson.serializer.SerializerFeature)6 SerializeConfig (com.alibaba.fastjson.serializer.SerializeConfig)3 JSONException (com.alibaba.fastjson.JSONException)2 JSONSerializer (com.alibaba.fastjson.serializer.JSONSerializer)2 NameFilter (com.alibaba.fastjson.serializer.NameFilter)2 PropertyFilter (com.alibaba.fastjson.serializer.PropertyFilter)2 SerializeWriter (com.alibaba.fastjson.serializer.SerializeWriter)2 ValueFilter (com.alibaba.fastjson.serializer.ValueFilter)2 Date (java.util.Date)2