Path: blob/master/test/jdk/sun/text/resources/Format/Bug8074791.java
41154 views
/*1* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 807479126* @modules jdk.localedata27* @summary Make sure that Finnish month names are correct in formatted text.28*/2930import java.text.DateFormat;31import java.text.SimpleDateFormat;32import java.util.Date;33import java.util.GregorianCalendar;34import java.util.Locale;35import static java.text.DateFormat.LONG;36import static java.util.Calendar.JANUARY;3738public class Bug8074791 {39private static Locale FINNISH = new Locale("fi");40private static String JAN_FORMAT = "tammikuuta";41private static String JAN_STANDALONE = "tammikuu";4243public static void main(String[] arg) {44int errors = 0;4546DateFormat df = DateFormat.getDateInstance(LONG, FINNISH);47Date jan20 = new GregorianCalendar(2015, JANUARY, 20).getTime();48String str = df.format(jan20).toString();49// Extract the month name (locale data dependent)50String month = str.replaceAll(".+\\s([a-z]+)\\s\\d+$", "$1");51if (!month.equals(JAN_FORMAT)) {52errors++;53System.err.println("wrong format month name: got '" + month54+ "', expected '" + JAN_FORMAT + "'");55}5657SimpleDateFormat sdf = new SimpleDateFormat("LLLL", FINNISH); // stand-alone month name58month = sdf.format(jan20);59if (!month.equals(JAN_STANDALONE)) {60errors++;61System.err.println("wrong stand-alone month name: got '" + month62+ "', expected '" + JAN_STANDALONE + "'");63}6465if (errors > 0) {66throw new RuntimeException();67}68}69}707172