jdk/test/javax/xml/jaxp/datatype/8033980/CalendarDuration1243Test.java
author joehw
Tue, 18 Feb 2014 10:53:18 -0800
changeset 22985 e9654c36f56d
permissions -rw-r--r--
8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl Reviewed-by: dfuchs, lancea, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22985
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     1
/*
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     4
 *
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     8
 *
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    13
 * accompanied this code).
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    14
 *
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    18
 *
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    21
 * questions.
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    22
 */
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    23
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    24
/**
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    25
 * @test
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    26
 * @bug 8033980
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    27
 * @summary verify that offset in minutes in getTimeZone is converted correctly
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    28
 * @run main CalendarDuration1243Test
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    29
 */
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    30
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    31
import javax.xml.datatype.DatatypeConfigurationException;
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    32
import javax.xml.datatype.DatatypeFactory;
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    33
import javax.xml.datatype.XMLGregorianCalendar;
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    34
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    35
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    36
/**
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    37
 *
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    38
 * @author Joe Wang huizhe.wang@oracle.com
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    39
 */
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    40
public class CalendarDuration1243Test {
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    41
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    42
    /**
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    43
     * main method.
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    44
     *
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    45
     * @param args Standard args.
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    46
     */
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    47
    public static void main(String[] args) {
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    48
        try {
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    49
            String dateTimeString = "2006-11-22T00:00:00.0+01:02";
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    50
            DatatypeFactory dtf = DatatypeFactory.newInstance();
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    51
            XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    52
            System.out.println( "XMLGregCal:" + cal.toString() );
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    53
            System.out.println( "GregCal:" + cal.toGregorianCalendar() );
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    54
            String toGCal = cal.toGregorianCalendar().toString();
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    55
            if (toGCal.indexOf("GMT+12:00") > -1) {
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    56
                throw new RuntimeException("Expected GMT+01:02");
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    57
            }
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    58
        } catch (DatatypeConfigurationException ex) {
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    59
            throw new RuntimeException(ex.getMessage());
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    60
        }
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    61
    }
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    62
e9654c36f56d 8033980: Xerces Update: datatype XMLGregorianCalendarImpl and DurationImpl
joehw
parents:
diff changeset
    63
}