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