Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6937964

XML Duration do not conform to W3C specifications

XMLWordPrintable

    • b09
    • sparc
    • solaris_10
    • Verified

        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");
         }
        }

              vikram Vikram Aroskar (Inactive)
              lkchow Lawrence Chow
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: