0

How does JAX-WS map an XML schema date (xs:dateTime) to a Java Date? In particular, if a JAX-WS server receives an xs:dateTime that contains a time zone, does JAX-WS translate the date to the server time zone? For example, suppose a server running JAX-WS is given an XML date of 2010-08-20T00:00:00-04:00 and the server operates in time zone UTC-5, after JAX-WS maps the date to Java Date property now, what string would now.toString() produce?

Given a collection of XML dates as input, JAX-WS will map these to a collection of Java Date objects, but in the log, to my surprise I see a mix of EST and EDT time zones when what I expect to see is all dates in EST, the current host time zone.

Derek Mahar
  • 27,608
  • 43
  • 124
  • 174
  • Yes, I have, but I observe the strange behaviour that I describe in the comments to http://stackoverflow.com/questions/4199217/what-time-zone-does-date-tostring-display/4199245#4199245. – Derek Mahar Nov 18 '10 at 02:02

1 Answers1

3

Date.toString() prints the time with respect to the server's timezone.

E.g.

SimpleTimeZone stz = new SimpleTimeZone(-18000000, "UTC-5");
TimeZone.setDefault(stz);

Means that all calls to Date.toString() will be of the format Fri Jan 01 0:00:00 GMT-5:00 2010

Consequently, if you had a web service that took in an input Date and returned it without any changes, it would be changed to match the server's timezone.

If you have any further questions, I'd suggest you just play with it yourself.

Catchwa
  • 5,845
  • 4
  • 31
  • 57
  • This is what I'd expect, but I've observed a collection of dates that, when printed, show a mix of EST and EDT time zones. Which library is the culprit? Is it JAX-WS, Logback 0.9.24, Apache Commons Lang 2.4 `ToStringBuilder.reflectionToString(Object)`, `Date.toString()`, `TimeZone`, the JVM? I asked this question thinking that JAX-WS might be the cause. – Derek Mahar Nov 18 '10 at 02:20