0

I'm using flexjson.JSONSerializer to serialize Java Object, but when serializes Date property, it is converted into Timestamp:

new JSONSerializer().exclude("*.class").serialize(obj);

How can flexjson convert from Date to String of readable time?

JerryCai
  • 1,663
  • 4
  • 21
  • 36

2 Answers2

1

You can use DateTransformer for the same.

 new JSONDeserializer().use("person.birthdate", new DateTransformer("yyyy/MM/dd hh:mm:ss") ).deserialize( people );
faizan
  • 680
  • 1
  • 6
  • 15
1

For the serializer you should use JSONSerializer#transform

new JSONSerializer().exclude("*.class")
    .transform(new DateTransformer("yyyy/MM/dd hh:mm:ss"), "creationDate")
    .serialize(obj);
nolith
  • 613
  • 6
  • 16