0

Can the Default Date format returned by Jettison Library can be changed ?

This is the default Date format

{ "post": { "activityDate": "2012-07-03T16:15:29.111-04:00", "modfiedDate": "2012-07-03T16:15:29.111-04:00", "createdDate": "2012-07-03T16:15:29.111-04:00" } }

can that be changed ?

We can do this in Jakson using org.codehaus.jackson.map.JsonSerialize annotation.

How to do this in Jettison ?

Is there any similar class in Jettison ?

Thanks

Swakesh
  • 233
  • 5
  • 15

1 Answers1

0

This is can be done using XMLAdapters

public class DateAdapter extends XmlAdapter {

/**
 * This method is called when we return the DTO Date property to UI, We
 * convert the date to UI  date format
 */
@Override
public String marshal(Date inputDate) throws Exception {

    .........

    return dateStr;
}

/**
 * This method is called when UI sends date String and we set the DTO Date
 * property
 */
@Override
public Date unmarshal(String inputDateStr) throws Exception {
            ................
    return inputdate;
}

}

Swakesh
  • 233
  • 5
  • 15