com.echomine.xmlrpc
Class DateSerializer
java.lang.Object
com.echomine.xmlrpc.DateSerializer
- All Implemented Interfaces:
- Deserializer, Serializer
public class DateSerializer
- extends java.lang.Object
- implements Serializer, Deserializer
the date serializer will work with parsing and serializing the Date format.
Currently, the way the date time is parsed defaults to the time zone that
you are in. XMLRPC specs indicate that the date timezone should be set
to the timezone of the server you are obtaining the response from.
For instance, if the remote time is sent as a UTC time (ie. 12pm) and you
are in PST time zone (GMT-800), then you should first set the timezone
of the DateSerializer to the remote server's timezone before any requests
are made. Then you can make the request and retrieve the time.
The time will then be in that timezone (ie. 12pm GMT). To convert to your
local timezone, you should set the timezone for the Date object you retrieved
from here and then work with it. It's a little complicated, but when specs
are unclear, the developer will have to work a bit more.
If you want to have a different timezone, what you need to do is first set
the time zone for the SerializerFactory before using XMLRPC inside your code.
Example:
<dateTime.iso8601>19980717T14:08:55</dateTime.iso8601>
Field Summary |
static java.lang.String |
NAME
|
Method Summary |
java.lang.Object |
deserialize(Element elem)
deserializes the element data into a date object. |
Element |
serialize(java.lang.Object data,
Namespace ns)
Serializes the Date object into an XML element. |
void |
setTimeZone(java.util.TimeZone tz)
sets the time zone to be used. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
DateSerializer
public DateSerializer()
serialize
public Element serialize(java.lang.Object data,
Namespace ns)
- Serializes the Date object into an XML element.
The object must be of type Date or its derivative.
- Specified by:
serialize
in interface Serializer
- Parameters:
data
- the Date object to be serializedns
- optional namespace, null if none
- Returns:
- the element data containing the date representation
- Throws:
java.lang.IllegalArgumentException
- if object is not of Date type
deserialize
public java.lang.Object deserialize(Element elem)
- deserializes the element data into a date object.
The method is synchronized to the internal date format so that
multithreading working through this method will not cause any problems.
- Specified by:
deserialize
in interface Deserializer
- Parameters:
elem
- the data for the date time
- Returns:
- a Date object representing the datetime, or null if the date cannot be parsed
setTimeZone
public void setTimeZone(java.util.TimeZone tz)
- sets the time zone to be used. By default, the timezone is your default local time zone
Copyright © 2001-2005 Echomine. All Rights Reserved.