jdk/test/sun/text/resources/Format/Bug8037343.java
author naoto
Wed, 24 Jun 2015 16:42:11 -0700
changeset 31263 a81a0af34ca0
parent 24511 5f539eb2a8a6
child 40801 9bf0aafeb2bb
permissions -rw-r--r--
8008577: Use CLDR Locale Data by Default Reviewed-by: erikj, okutsu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24511
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     1
/*
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     4
 *
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     8
 *
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    13
 * accompanied this code).
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    14
 *
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    18
 *
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    21
 * questions.
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    22
 */
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    23
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    24
/*
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    25
 * @test
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 24511
diff changeset
    26
 * @bug 8008577 8037343
24511
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    27
 * @summary updating dateformat for es_DO
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 24511
diff changeset
    28
 * @run main/othervm -Djava.locale.providers=JRE,SPI Bug8037343
24511
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    29
 */
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    30
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    31
import java.text.DateFormat;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    32
import java.util.Calendar;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    33
import java.util.Locale;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    34
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    35
public class Bug8037343
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    36
{
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    37
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    38
    public static void main(String[] arg)
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    39
    {
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    40
        final Locale esDO = new Locale("es", "DO");
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    41
        final String expectedShort = "31/03/12";
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    42
        final String expectedMedium = "31/03/2012";
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    43
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    44
        int errors = 0;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    45
        DateFormat format;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    46
        String result;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    47
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    48
        Calendar cal = Calendar.getInstance(esDO);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    49
        cal.set(Calendar.DAY_OF_MONTH, 31);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    50
        cal.set(Calendar.MONTH, Calendar.MARCH);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    51
        cal.set(Calendar.YEAR, 2012);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    52
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    53
        format = DateFormat.getDateInstance(DateFormat.SHORT, esDO);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    54
        result = format.format(cal.getTime());
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    55
        if (!expectedShort.equals(result)) {
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    56
            System.out.println(String.format("Short Date format for es_DO is not as expected. Expected: [%s] Actual: [%s]", expectedShort, result));
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    57
            errors++;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    58
        }
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    59
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    60
        format = DateFormat.getDateInstance(DateFormat.MEDIUM, esDO);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    61
        result = format.format(cal.getTime());
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    62
        if (!expectedMedium.equals(result)) {
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    63
            System.out.println(String.format("Medium Date format for es_DO is not as expected. Expected: [%s] Actual: [%s]", expectedMedium, result));
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    64
            errors++;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    65
        }
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    66
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    67
        if (errors > 0) {
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    68
            throw new RuntimeException();
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    69
        }
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    70
    }
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    71
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    72
}