XML DURATIONS DO NOT CONFORM TO W3C SPECIFICATIONS (Oracle Bug 9477446 ) Expected output: Answer should be in canonical form, i.e. 21 years, 3 months. Actual output: 20 years, 15 months. This appears to be a bug in javax.xml.datatype.Duration or DatatypeFactory. JDK: 6u18-b09 (latest) /* test case */ import javax.xml.datatype.*; public class Bug { public static void main(String[] args) throws DatatypeConfigurationException { DatatypeFactory dtf = DatatypeFactory.newInstance(); Duration d = dtf.newDuration("P20Y15M"); System.out.println(d.getYears()==21 ? "pass" : "fail"); } }
|