Inside my entity class I have a column of type timestamp:
@Column(name = "TESTD")
@Temporal(TemporalType.TIMESTAMP)
private Date test_date;
Inside my session bean I’m creating a select query which return a resultList, and then I’m creating from it a json object:
Query query = em.createNamedQuery("findAllTest");
List<entityClass> results = query.getResultList();
JSONSerializer.toJSON((List)results ,jsonConfig);
when creating the json object I want the timestamp column to be formatted (and not to return as object). How can this be done? how can I cast/format the timestamp column according to the date format I want? what is the best way to do this?
I guess you’re using json-lib, based on the code sample, and I’ve never used it, but the javadoc shows that JsonConfig provides the following method:
So I guess you could use that method, and register a processor for Calendar.class that would transform the Calendar object into a String using the format you want..