ankitp 2005/05/11 13:52:00
Modified: java/samples/jaxp DatatypeAPITest.java
Log:
update
Revision Changes Path
1.2 +10 -3 xml-xerces/java/samples/jaxp/DatatypeAPITest.java
Index: DatatypeAPITest.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/jaxp/DatatypeAPITest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DatatypeAPITest.java 11 May 2005 20:42:43 -0000 1.1
+++ DatatypeAPITest.java 11 May 2005 20:52:00 -0000 1.2
@@ -10,7 +10,6 @@
DatatypeFactory df = DatatypeFactory.newInstance();
// my work number in milliseconds:
Duration myPhone = df.newDuration(9054133519l);
- // my approximate life span up to the conference
Duration myLife = df.newDuration(true, 29, 2, 15, 13, 45, 0);
int compareVal = myPhone.compare(myLife);
switch (compareVal) {
@@ -27,10 +26,14 @@
System.out.println("The comparison could not be carried out.");
}
- // create a yearmonthDuration
+ // create a yearMonthDuration
Duration ymDuration = df.newDurationYearMonth("P12Y10M");
System.out.println("P12Y10M is of type: " +
ymDuration.getXMLSchemaType());
+ // create a dayTimeDuration
+ Duration dtDuration = df.newDurationDayTime("P12Y10M");
+ System.out.println("P12Y10M is of type: " +
dtDuration.getXMLSchemaType());
+
// try to fool the factory!
try {
ymDuration = df.newDurationYearMonth("P12Y10M1D");
@@ -51,6 +54,10 @@
xgc.add(myPhone);
System.out.println("The approximate end of the number of
milliseconds in my phone number was " + xgc);
+ //adding a duration to XMLGregorianCalendar
+ xgc.add(myLife);
+ System.out.println("Adding the duration myLife to the above
calendar:" + xgc);
+
// create a new XMLGregorianCalendar using the string format of xgc.
XMLGregorianCalendar xgc_copy =
df.newXMLGregorianCalendar(xgc.toXMLFormat());
@@ -59,7 +66,7 @@
System.out.println("oooops!");
}
else {
- System.out.println("Very good: " + xgc + " is values are equal
to " + xgc_copy);
+ System.out.println("Very good: " + xgc + " is equal to " +
xgc_copy);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]