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

incorrect result of Duration.toString() for very short durations

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Name: erR10175 Date: 10/22/2003



          The method javax.xml.datatype.Duration.toString() returns illegal string representations for
        very short durations. For example:
        new Duration("PT0.00000000000000001S").toString() returns "PT1E-17S".

        The documentation of the method 'toString()' reads:
        "Returns a string representation of this duration object. The result is formatter according to
        the XML Schema 1.0 spec and can be always parsed back later into the equivalent duration object
        by the Duration(String) constructor." In our case, the value "PT1E-17S" cannot be parsed back,
        so the method 'toString' has a bug.

        This bug affects new test in JCK 1.5 (not yet integrated)
           api/javax_xml/datatype/Duration/index.html#DurationTests[Ctor010]

        To reproduce the bug compile and run the following code as shown
        in the log below:
        ------------------------------ test.java
        import javax.xml.datatype.Duration;

        public class test {
            public static void main(String [] args) {
                System.out.println(
                     "new Duration(\"PT0.00000000000000001S\").toString() returns "
                    + new Duration("PT0.00000000000000001S").toString());
            }
        }
        ----------------------------------------------------

        ------------------------------------------------ log
        $javac test.java
        novo148:/home/rey/links/WS/jck15-beta/tests/api/javax_xml/datatype/Duration
        $java -cp . -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b24)
        Java HotSpot(TM) Server VM (build 1.5.0-beta-b24, mixed mode)

        new Duration("PT0.00000000000000001S").toString() returns PT1E-17S
        ----------------------------------------------------

        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                kkawagucsunw Kohsuke Kawaguchi (Inactive)
                Reporter:
                reysunw Rey Rey (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: