I have a Tomcat server app, which creates xml responses based on classes I populate.
One of the classes has a date field:
@XmlRootElement
public class Login {
private String mLoginUserID;
private String mLoginPassword;
private Date mRecordChangeDateTime;
...
@XmlElement(name = "recordChangeDateTime")
public Date getRecordChangeDateTime() {
return mRecordChangeDateTime;
}
The resulting XML output looks like:
<recordChangeDateTime>2011-08-02T21:03:00-04:00</recordChangeDateTime>
Couple problems I am trying to figure out...
1) Its converting the date to local timezone, the date is handled as UTC all the way throughout, but when javax.xml outputs it, it applies the timezone conversion.
2) I am trying to configure how the date is formatted. My standard format is "yyyy-MM-dd HH:mm:ss" across my client devices, and would like the xml response to use this format as well.
I having been spending many many hours researching and trying to work through this, I have attempted lots of variations of SimpleDateFormat, XMLGregorianCalendar, etc... but nothing I do changes the output in anyway... I am not sure if there is an annotation or something else that allows me to configure the date output programmatically?
Any insights would be greatly appreciated! Thanks,