jdk/test/sun/text/resources/Format/Bug8037343.java
author alexsch
Thu, 31 Jul 2014 14:28:10 +0400
changeset 26019 10a56d28f48d
parent 24511 5f539eb2a8a6
child 31263 a81a0af34ca0
permissions -rw-r--r--
8051838: [Findbugs]sun.awt.image.MultiResolutionCachedImage expose internal representation Reviewed-by: serb, pchelko
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
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    26
 * @bug 8037343
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    27
 * @summary updating dateformat for es_DO
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    28
 */
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
import java.text.DateFormat;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    31
import java.util.Calendar;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    32
import java.util.Locale;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    33
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    34
public class Bug8037343
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    35
{
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
    public static void main(String[] arg)
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    38
    {
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    39
        final Locale esDO = new Locale("es", "DO");
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    40
        final String expectedShort = "31/03/12";
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    41
        final String expectedMedium = "31/03/2012";
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    42
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    43
        int errors = 0;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    44
        DateFormat format;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    45
        String result;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    46
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    47
        Calendar cal = Calendar.getInstance(esDO);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    48
        cal.set(Calendar.DAY_OF_MONTH, 31);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    49
        cal.set(Calendar.MONTH, Calendar.MARCH);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    50
        cal.set(Calendar.YEAR, 2012);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    51
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    52
        format = DateFormat.getDateInstance(DateFormat.SHORT, esDO);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    53
        result = format.format(cal.getTime());
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    54
        if (!expectedShort.equals(result)) {
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    55
            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
    56
            errors++;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    57
        }
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
        format = DateFormat.getDateInstance(DateFormat.MEDIUM, esDO);
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    60
        result = format.format(cal.getTime());
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    61
        if (!expectedMedium.equals(result)) {
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    62
            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
    63
            errors++;
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    64
        }
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
        if (errors > 0) {
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    67
            throw new RuntimeException();
5f539eb2a8a6 8037343: Wrong dateformat for locale es_DO
mfang
parents:
diff changeset
    68
        }
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
}