jdk/test/sun/text/resources/Format/Bug8074791.java
author jlaskey
Fri, 20 May 2016 11:41:29 -0300
changeset 38445 0a88d86065f9
parent 29391 b4fad461f2b5
child 40801 9bf0aafeb2bb
permissions -rw-r--r--
8156602: javac crashes again on Windows 32-bit with ClosedChannelException Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29391
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     1
/*
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     4
 *
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     8
 *
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    13
 * accompanied this code).
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    14
 *
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    18
 *
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    21
 * questions.
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    22
 */
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    23
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    24
/*
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    25
 * @test
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    26
 * @bug 8074791
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    27
 * @summary Make sure that Finnish month names are correct in formatted text.
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    28
 */
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    29
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    30
import java.text.DateFormat;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    31
import java.text.SimpleDateFormat;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    32
import java.util.Date;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    33
import java.util.GregorianCalendar;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    34
import java.util.Locale;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    35
import static java.text.DateFormat.*;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    36
import static java.util.Calendar.JANUARY;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    37
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    38
public class Bug8074791 {
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    39
    private static Locale FINNISH = new Locale("fi");
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    40
    private static String JAN_FORMAT = "tammikuuta";
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    41
    private static String JAN_STANDALONE = "tammikuu";
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    42
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    43
    public static void main(String[] arg) {
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    44
        int errors = 0;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    45
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    46
        DateFormat df = DateFormat.getDateInstance(LONG, FINNISH);
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    47
        Date jan20 = new GregorianCalendar(2015, JANUARY, 20).getTime();
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    48
        String str = df.format(jan20).toString();
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    49
        // Extract the month name (locale data dependent)
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    50
        String month = str.replaceAll(".+\\s([a-z]+)\\s\\d+$", "$1");
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    51
        if (!month.equals(JAN_FORMAT)) {
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    52
            errors++;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    53
            System.err.println("wrong format month name: got '" + month
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    54
                               + "', expected '" + JAN_FORMAT + "'");
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    55
        }
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    56
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    57
        SimpleDateFormat sdf = new SimpleDateFormat("LLLL", FINNISH); // stand-alone month name
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    58
        month = sdf.format(jan20);
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    59
        if (!month.equals(JAN_STANDALONE)) {
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    60
            errors++;
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    61
            System.err.println("wrong stand-alone month name: got '" + month
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    62
                               + "', expected '" + JAN_STANDALONE + "'");
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    63
        }
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    64
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    65
        if (errors > 0) {
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    66
            throw new RuntimeException();
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    67
        }
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    68
    }
b4fad461f2b5 8074791: Long-form date format incorrect month string for Finnish locale
okutsu
parents:
diff changeset
    69
}