You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by st...@apache.org on 2004/06/16 13:28:08 UTC
cvs commit: ws-axis/java/src/org/apache/axis/types Time.java
stevel 2004/06/16 04:28:08
Modified: java/test/encoding TestDeser2001.java
java/src/org/apache/axis/types Time.java
Log:
more debugging/testing of a deserialization problem I am having.
Revision Changes Path
1.29 +50 -11 ws-axis/java/test/encoding/TestDeser2001.java
Index: TestDeser2001.java
===================================================================
RCS file: /home/cvs/ws-axis/java/test/encoding/TestDeser2001.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- TestDeser2001.java 26 Dec 2003 15:18:49 -0000 1.28
+++ TestDeser2001.java 16 Jun 2004 11:28:07 -0000 1.29
@@ -122,12 +122,23 @@
deserializeCalendar(TimeZone.getTimeZone("PST8PDT"));
}
*/
-
+
+ /**
+ * this isnt a test, it is here to list timezones
+ */
+
+ public void NotestListTimeZones() throws Exception {
+ String ids[] = TimeZone.getAvailableIDs();
+ for (int i = 9; i < ids.length; i++) {
+ System.out.println(ids[i]);
+ }
+ }
+
/**
- * test that this works in Wintertime
+ * test local time costs
* @throws Exception
*/
- public void testTimeLocal() throws Exception {
+ public void NotestTimeLocal() throws Exception {
deserializeCalendar(TimeZone.getDefault());
}
@@ -135,10 +146,31 @@
// * test that this works in Wintertime
// * @throws Exception
// */
-// public void testTimeUK() throws Exception {
-// deserializeCalendar(TimeZone.getTimeZone("GMT0BST"));
-// }
+ public void testTimeUKWinter() throws Exception {
+ deserializeCalendar(TimeZone.getTimeZone("GMT+0:00"));
+ }
+ public void testTimeUKSummer() throws Exception {
+ deserializeCalendar(TimeZone.getTimeZone("GMT+1:00"));
+ }
+
+ public void testTimeUK() throws Exception {
+ deserializeCalendar(TimeZone.getTimeZone("Europe/London"));
+ }
+
+ /**
+ * this test is here to track down odd behaviour on one system related to these TZ tests
+ *
+ */
+ public void testTimeZoneLogicWorks() {
+
+ TimeZone tz=TimeZone.getTimeZone("GMT");
+ assertEquals(0,tz.getDSTSavings());
+ assertEquals(0,tz.getRawOffset());
+ Time time=new Time("12:01:30.150+00:00");
+ String timeVal=time.toString();
+ assertEquals("12:01:30.150Z",timeVal);
+ }
private void deserializeCalendar(TimeZone tz) throws Exception {
deserializeCalendar(2004, 1, 1, tz);
@@ -157,7 +189,9 @@
date.setTimeZone(tz);
Time time = new Time(date);
String offset = calcGMTOffset(date);
- String comment=" [time="+time.toString()+"; tz="+tz.getDisplayName()+"]";
+ //diagnostics string
+ String comment=" [time="+time.toString()+"; tz="+tz.getDisplayName()
+ +"; offset="+offset+"]";
deserialize("<result xsi:type=\"xsd:time\">" +
"12:01:30.150" + offset +
@@ -168,8 +202,8 @@
}
- private static final int msecsInMinute = 60000;
- private static final int msecsInHour = 60 * msecsInMinute;
+ private static final int MILLISECONDS_IN_MINUTE = 60000;
+ private static final int MILLISECONDS_IN_HOUR = 60 * MILLISECONDS_IN_MINUTE;
/**
*
@@ -183,11 +217,11 @@
private String calcGMTOffset(Calendar cal) {
int msecOffset = cal.get(Calendar.ZONE_OFFSET) +
cal.get(Calendar.DST_OFFSET);
- int hourOffset = Math.abs(msecOffset / msecsInHour);
+ int hourOffset = Math.abs(msecOffset / MILLISECONDS_IN_HOUR);
String offsetString = msecOffset > 0 ? "+" : "-";
offsetString += hourOffset >= 10 ? "" + hourOffset : "0" + hourOffset;
offsetString += ":";
- int minOffset = Math.abs(msecOffset % msecsInHour);
+ int minOffset = Math.abs(msecOffset % MILLISECONDS_IN_HOUR);
if (minOffset == 0) {
offsetString += "00";
}
@@ -376,5 +410,10 @@
uri = new URI("http", "www.macromedia.com", "/testing", "query=1", null);
deserialize("<result xsi:type=\"xsd:anyURI\">http://www.macromedia.com/testing?query=1</result>",
uri);
+ }
+
+ public static void main() throws Exception {
+ TestDeser2001 deser=new TestDeser2001("");
+ deser.testTimeUKWinter();
}
}
1.11 +6 -2 ws-axis/java/src/org/apache/axis/types/Time.java
Index: Time.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/types/Time.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Time.java 5 Mar 2004 16:29:56 -0000 1.10
+++ Time.java 16 Jun 2004 11:28:07 -0000 1.11
@@ -192,8 +192,9 @@
Date date;
try {
synchronized (zulu) {
- date = zulu.parse(source == null ? null :
- (source.substring(0,8)+".000Z") );
+ String fulltime = source == null ? null :
+ (source.substring(0,8)+".000Z");
+ date = zulu.parse(fulltime);
}
} catch (Exception e) {
throw new NumberFormatException(e.toString());
@@ -225,6 +226,9 @@
* @return
*/
public String toString() {
+ if(_value==null) {
+ return "unassigned Time";
+ }
synchronized (zulu) {
return zulu.format(_value.getTime());
}