Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/text/resources/Format/Bug8074791.java
38855 views
1
/*
2
* Copyright (c) 2015, 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
* @summary Make sure that Finnish month names are correct in formatted text.
28
*/
29
30
import java.text.DateFormat;
31
import java.text.SimpleDateFormat;
32
import java.util.Date;
33
import java.util.GregorianCalendar;
34
import java.util.Locale;
35
import static java.text.DateFormat.*;
36
import static java.util.Calendar.JANUARY;
37
38
public class Bug8074791 {
39
private static Locale FINNISH = new Locale("fi");
40
private static String JAN_FORMAT = "tammikuuta";
41
private static String JAN_STANDALONE = "tammikuu";
42
43
public static void main(String[] arg) {
44
int errors = 0;
45
46
DateFormat df = DateFormat.getDateInstance(LONG, FINNISH);
47
Date jan20 = new GregorianCalendar(2015, JANUARY, 20).getTime();
48
String str = df.format(jan20).toString();
49
// Extract the month name (locale data dependent)
50
String month = str.replaceAll(".+\\s([a-z]+)\\s\\d+$", "$1");
51
if (!month.equals(JAN_FORMAT)) {
52
errors++;
53
System.err.println("wrong format month name: got '" + month
54
+ "', expected '" + JAN_FORMAT + "'");
55
}
56
57
SimpleDateFormat sdf = new SimpleDateFormat("LLLL", FINNISH); // stand-alone month name
58
month = sdf.format(jan20);
59
if (!month.equals(JAN_STANDALONE)) {
60
errors++;
61
System.err.println("wrong stand-alone month name: got '" + month
62
+ "', expected '" + JAN_STANDALONE + "'");
63
}
64
65
if (errors > 0) {
66
throw new RuntimeException();
67
}
68
}
69
}
70
71