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

toGregorianCalendar(...) does not use the defaults XMLGregorianCalendar paramete

    XMLWordPrintable

Details

    • 1.3
    • generic
    • generic

    Backports

      Description

        Name: erR10175 Date: 04/30/2004



         The following method in the class javax.xml.datatype.XMLGregorianCalendar

        public GregorianCalendar toGregorianCalendar(TimeZone timezone, Locale aLocale
                                                   , XMLGregorianCalendar defaults)

        does not use the parameter 'defaults' to set default field values of the newly
        created GregorianCalendar instance.

        The javadoc of the method reads:
        "
        Parameters:
            ...
            defaults - provide default field values to use when corresponding field for this
                       instance is FIELD_UNDEFINED or null. If defaults is null or a field
                       within the specified defaults is undefined, just use
                       java.util.GregorianCalendar defaults.
        "

        So the sample (see below) should report "Passed: OK".

        The bug affects the following new JCK-15 beta2 test:

          api/javax_xml/datatype/XMLGregorianCalendar/index.html#ConvertTo[ToGregorianCalendar007]

        The bug is found in jdk1.5.0/beta2/b49 while verifying the following bug:

        5030130 XMLGregorianCalendar.toGregorianCalendar methods do not set default values

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

        class test {
            public static void main(String [] args) throws Exception {
                XMLGregorianCalendar time_16_17_18 =
                  XMLGregorianCalendar.parse("16:17:18");
                XMLGregorianCalendar date_2001_02_03 =
                  XMLGregorianCalendar.parse("2001-02-03");
                GregorianCalendar calendar = date_2001_02_03.toGregorianCalendar(
                    null, null, time_16_17_18);

                int year = calendar.get(GregorianCalendar.YEAR);
                int minute = calendar.get(GregorianCalendar.MINUTE);
                if (year != 2001 || minute != 17) {
                    System.out.println("Failed: year = " + year + ", minute = "
                                 + minute + "; expected year = 2001, minute = 17");
                } else
                    System.out.println("Passed: OK");
            }
        }
        -------------------------------------

        --------------------------------- log
        $javac test.java && java -showversion test
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b49)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b49, mixed mode)

        Failed: year = 2001, minute = 0; expected year = 2001, minute = 17
        -------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

                jsuttorsunw Jeff Suttor (Inactive)
                reysunw Rey Rey (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: