Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/text/resources/Format/Bug8074791.java
38855 views
/*1* Copyright (c) 2015, 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* @summary Make sure that Finnish month names are correct in formatted text.27*/2829import java.text.DateFormat;30import java.text.SimpleDateFormat;31import java.util.Date;32import java.util.GregorianCalendar;33import java.util.Locale;34import static java.text.DateFormat.*;35import static java.util.Calendar.JANUARY;3637public class Bug8074791 {38private static Locale FINNISH = new Locale("fi");39private static String JAN_FORMAT = "tammikuuta";40private static String JAN_STANDALONE = "tammikuu";4142public static void main(String[] arg) {43int errors = 0;4445DateFormat df = DateFormat.getDateInstance(LONG, FINNISH);46Date jan20 = new GregorianCalendar(2015, JANUARY, 20).getTime();47String str = df.format(jan20).toString();48// Extract the month name (locale data dependent)49String month = str.replaceAll(".+\\s([a-z]+)\\s\\d+$", "$1");50if (!month.equals(JAN_FORMAT)) {51errors++;52System.err.println("wrong format month name: got '" + month53+ "', expected '" + JAN_FORMAT + "'");54}5556SimpleDateFormat sdf = new SimpleDateFormat("LLLL", FINNISH); // stand-alone month name57month = sdf.format(jan20);58if (!month.equals(JAN_STANDALONE)) {59errors++;60System.err.println("wrong stand-alone month name: got '" + month61+ "', expected '" + JAN_STANDALONE + "'");62}6364if (errors > 0) {65throw new RuntimeException();66}67}68}697071