Friday, November 21, 2008

Apache Axis and Dates

Recently, I began working on an existing application where the web service implementation was built using Apache Axis. It didn’t take long to notice that Axis was ignoring the timezone that I had set in my calendar objects. After investigating further, I found that the default behavior of Axis was to convert all the dates to “GMT”. Take a look at the following code in the org.apache.axis.encoding.ser package…



And...


Because of this, all dates that were not set to “GMT” before they are serialized/deserialized resulted in having incorrect times. If your time zones uses “GMT, then Axis seems to handle this just fine. Otherwise, you could go about fixing this in several different ways. You could change the “GMT” string to whatever timezone you application uses, or perhaps a better solution would be to read the timezone from a property so that it can easily be changed in the future. In my case, I was able to read a property string of “EST” since I am using eastern time. After making the change, you can use Ant or whatever build tool you are familiar with to recompile and package Axis for your application.

No comments: