openamf/src/java/org/openamf/io AMFDeserializer.java,1.35,1.36
[email protected] Wed, 20 Aug 2003 18:05:18 -0700
| Newsgroups | gmane.comp.java.openamf.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openamf/openamf/src/java/org/openamf/io
In directory sc8-pr-cvs1:/tmp/cvs-serv32248/src/java/org/openamf/io
Modified Files:
AMFDeserializer.java
Log Message:
fixed bug with date deserializing related to timezone and daylight savings correction
Index: AMFDeserializer.java
===================================================================
RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/io/AMFDeserializer.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** AMFDeserializer.java 20 Aug 2003 22:30:18 -0000 1.35
--- AMFDeserializer.java 21 Aug 2003 01:05:16 -0000 1.36
***************
*** 10,16 ****
import java.io.DataInputStream;
import java.io.IOException;
! import java.util.ArrayList;
! import java.util.Date;
! import java.util.List;
import org.apache.commons.logging.Log;
--- 10,14 ----
import java.io.DataInputStream;
import java.io.IOException;
! import java.util.*;
import org.apache.commons.logging.Log;
***************
*** 250,261 ****
protected Date readDate() throws IOException {
long ms = (long) inputStream.readDouble(); // Date in millis from 01/01/1970
! int timeoffset = inputStream.readUnsignedShort();
! if (timeoffset > 720) {
! // I haven't tested this
! timeoffset = -(65536 - timeoffset);
! }
! ms += timeoffset;
! Date date = new Date(ms);
! return date;
}
--- 248,274 ----
protected Date readDate() throws IOException {
long ms = (long) inputStream.readDouble(); // Date in millis from 01/01/1970
!
! // here we have to read in the raw
! // timezone offset (which comes in minutes, but incorrectly signed),
! // make it millis, and fix the sign.
! int timeoffset = inputStream.readShort() * 60000 * -1; // now we have millis
!
! TimeZone serverTimeZone = TimeZone.getDefault();
!
! // now we subtract the current timezone offset and add the one that was passed
! // in (which is of the Flash client), which gives us the appropriate ms (i think)
! // -alon
! Calendar sent = new GregorianCalendar();
! sent.setTimeInMillis(ms - serverTimeZone.getRawOffset() + timeoffset);
!
! TimeZone sentTimeZone = sent.getTimeZone();
!
! // we have to handle daylight savings ms as well
! if (sentTimeZone.inDaylightTime(sent.getTime()))
! {
! sent.setTimeInMillis(sent.getTimeInMillis() - sentTimeZone.getDSTSavings());
! }
!
! return sent.getTime();
}
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0