8283698: Refactor Locale constructors used in src/test

Reviewed-by: iris, joehw
This commit is contained in:
Naoto Sato 2022-04-08 15:23:25 +00:00
parent 61698bd137
commit d6b4693c05
182 changed files with 747 additions and 747 deletions

View File

@ -74,7 +74,7 @@ import java.util.stream.Collectors;
*
* <blockquote><pre>
* NumberFormat fmt = NumberFormat.getCompactNumberInstance(
* new Locale("hi", "IN"), NumberFormat.Style.SHORT);
* Locale.forLanguageTag("hi-IN"), NumberFormat.Style.SHORT);
* String result = fmt.format(1000);
* </pre></blockquote>
*

View File

@ -2438,7 +2438,7 @@ public abstract class ResourceBundle {
* import static java.util.ResourceBundle.Control.*;
* ...
* ResourceBundle bundle =
* ResourceBundle.getBundle("MyResources", new Locale("fr", "CH"),
* ResourceBundle.getBundle("MyResources", Locale.forLanguageTag("fr-CH"),
* ResourceBundle.Control.getControl(FORMAT_PROPERTIES));
* </pre>
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -94,16 +94,16 @@ public class BasicTest {
ComponentOrientation orient = ComponentOrientation.getOrientation(Locale.US);
Assert(orient == ComponentOrientation.LEFT_TO_RIGHT, "US == LEFT_TO_RIGHT");
orient = ComponentOrientation.getOrientation(new Locale("iw", ""));
orient = ComponentOrientation.getOrientation(Locale.of("iw"));
Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "iw == RIGHT_TO_LEFT");
orient = ComponentOrientation.getOrientation(new Locale("ar", ""));
orient = ComponentOrientation.getOrientation(Locale.of("ar"));
Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "ar == RIGHT_TO_LEFT");
orient = ComponentOrientation.getOrientation(new Locale("he", ""));
orient = ComponentOrientation.getOrientation(Locale.of("he"));
Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "he == RIGHT_TO_LEFT");
orient = ComponentOrientation.getOrientation(new Locale("yi", ""));
orient = ComponentOrientation.getOrientation(Locale.of("yi"));
Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "yi == RIGHT_TO_LEFT");
System.out.println(" } Pass");
@ -119,8 +119,8 @@ public class BasicTest {
// This will fall back to the default locale's bundle or root bundle
ResourceBundle rb = ResourceBundle.getBundle("TestBundle",
new Locale("et", ""));
if (rb.getLocale().getLanguage().equals(new Locale("iw").getLanguage())) {
Locale.of("et"));
if (rb.getLocale().getLanguage().equals(Locale.of("iw").getLanguage())) {
assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "et == RIGHT_TO_LEFT" );
} else if (rb.getLocale().getLanguage() == "es") {
assertEquals(rb, ComponentOrientation.LEFT_TO_RIGHT, "et == LEFT_TO_RIGHT" );
@ -130,19 +130,19 @@ public class BasicTest {
// We have actual bundles for "es" and "iw", so it should just fetch
// the orientation object out of them
rb = ResourceBundle.getBundle("TestBundle",new Locale("es", ""));
rb = ResourceBundle.getBundle("TestBundle",Locale.of("es"));
assertEquals(rb, ComponentOrientation.LEFT_TO_RIGHT, "es == LEFT_TO_RIGHT" );
rb = ResourceBundle.getBundle("TestBundle", new Locale("iw", "IL"));
rb = ResourceBundle.getBundle("TestBundle", Locale.of("iw", "IL"));
assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "iw == RIGHT_TO_LEFT" );
// Test with "he" locale. This should load TestBundle_iw and fetch the orientation from there
rb = ResourceBundle.getBundle("TestBundle", new Locale("he", "IL"));
rb = ResourceBundle.getBundle("TestBundle", Locale.of("he", "IL"));
assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "he == RIGHT_TO_LEFT" );
// This bundle has no orientation setting at all, so we should get
// the system's default orientation for Arabic
rb = ResourceBundle.getBundle("TestBundle1", new Locale("ar", ""));
rb = ResourceBundle.getBundle("TestBundle1", Locale.of("ar"));
assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "ar == RIGHT_TO_LEFT" );
System.out.println(" } Pass");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -98,12 +98,12 @@ public class WindowTest {
ResourceBundle.getBundle("TestBundle1", Locale.getDefault())));
System.out.println(" Applying TestBundle_iw and verifying...");
rb = ResourceBundle.getBundle("TestBundle", new Locale("iw", ""));
rb = ResourceBundle.getBundle("TestBundle", Locale.of("iw"));
myFrame.applyResourceBundle(rb);
verifyOrientation(myFrame, ComponentOrientation.RIGHT_TO_LEFT);
System.out.println(" Applying TestBundle_es and verifying...");
rb = ResourceBundle.getBundle("TestBundle", new Locale("es", ""));
rb = ResourceBundle.getBundle("TestBundle", Locale.of("es"));
myFrame.applyResourceBundle(rb);
verifyOrientation(myFrame, ComponentOrientation.LEFT_TO_RIGHT);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -52,12 +52,12 @@ public class GetLCIDFromLocale {
test(Locale.US, 0x0409);
test(Locale.GERMAN, 0x0407);
test(Locale.GERMANY, 0x0407);
test(new Locale("de", "AT"), 0x0c07);
test(new Locale("ar"), 0x0401);
test(new Locale("ar", "SA"), 0x0401);
test(new Locale("ar", "EG"), 0x0c01);
test(new Locale("??"), 0x0409);
test(new Locale("??", "??"), 0x0409);
test(Locale.of("de", "AT"), 0x0c07);
test(Locale.of("ar"), 0x0401);
test(Locale.of("ar", "SA"), 0x0401);
test(Locale.of("ar", "EG"), 0x0c01);
test(Locale.of("??"), 0x0409);
test(Locale.of("??", "??"), 0x0409);
test(Locale.KOREA, 0x0412);
}

View File

@ -1,6 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -42,7 +41,7 @@ public class TrueTypeFontLocaleNameTest {
}
System.setProperty("user.language", "de");
System.setProperty("user.country", "AT");
Locale de_atLocale = new Locale("de", "AT");
Locale de_atLocale = Locale.of("de", "AT");
Locale.setDefault(de_atLocale);
String family = "Verdana";
@ -53,7 +52,7 @@ public class TrueTypeFontLocaleNameTest {
}
String atFontName = font.getFontName();
Locale deGELocale = new Locale("de", "GE");
Locale deGELocale = Locale.of("de", "GE");
String deFontName = font.getFontName(deGELocale);
System.out.println("Austrian font name: " + atFontName);
System.out.println("German font name: " + deFontName);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,7 +35,7 @@ import java.util.Locale;
import static java.util.Locale.ENGLISH;
public class Test6341798 {
private static final Locale TURKISH = new Locale("tr");
private static final Locale TURKISH = Locale.of("tr");
private static final String DATA
= "<java>\n"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -39,7 +39,7 @@ public class bug6344646 {
return;
}
Locale.setDefault(new Locale("lt"));
Locale.setDefault(Locale.of("lt"));
File f1 = new File("J\u0301");
File f2 = new File("j\u0301");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,7 @@ import java.util.*;
import static java.lang.Character.*;
public class DumpCharProperties {
final static Locale turkish = new Locale("tr");
final static Locale turkish = Locale.of("tr");
static String charProps(int i) {
String s = new String(new int[]{i},0,1);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -45,7 +45,7 @@ public class UnicodeCasingTest {
// Locales which are used for testing
private static List<Locale> locales = new ArrayList<>();
static {
locales.add(new Locale("az", ""));
locales.add(Locale.of("az"));
locales.addAll(java.util.Arrays.asList(Locale.getAvailableLocales()));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,11 +28,11 @@
*/
import java.util.Locale;
import static java.util.Locale.ENGLISH;
public class NonCharacterMapping {
private static final Locale ENGLISH = new Locale("en");
private static final Locale TURKISH = new Locale("tr");
private static final Locale TURKISH = Locale.of("tr");
public static void main(String[] args) {
if (Character.toLowerCase('\uFFFF') != '\uFFFF') {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -47,7 +47,7 @@ public class SpecialCasingTest {
// Locales which are used for testing
private static List<Locale> locales = new ArrayList<>();
static {
locales.add(new Locale("az", ""));
locales.add(Locale.of("az"));
locales.addAll(java.util.Arrays.asList(Locale.getAvailableLocales()));
}
@ -302,7 +302,7 @@ public class SpecialCasingTest {
private void testLowerCase(String orig, String expected,
String lang, String condition) {
String got = (lang == null) ?
orig.toLowerCase() : orig.toLowerCase(new Locale(lang, ""));
orig.toLowerCase() : orig.toLowerCase(Locale.of(lang));
if (!expected.equals(got)) {
err = true;
@ -318,7 +318,7 @@ public class SpecialCasingTest {
private void testUpperCase(String orig, String expected,
String lang, String condition) {
String got = (lang == null) ?
orig.toUpperCase() : orig.toUpperCase(new Locale(lang, ""));
orig.toUpperCase() : orig.toUpperCase(Locale.of(lang));
if (!expected.equals(got)) {
err = true;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,9 +35,9 @@ import java.util.Locale;
public class ToLowerCase {
public static void main(String[] args) {
Locale turkish = new Locale("tr", "TR");
Locale lt = new Locale("lt"); // Lithanian
Locale az = new Locale("az"); // Azeri
Locale turkish = Locale.of("tr", "TR");
Locale lt = Locale.of("lt"); // Lithanian
Locale az = Locale.of("az"); // Azeri
// Greek Sigma final/non-final tests
test("\u03A3", Locale.US, "\u03C3");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,9 +36,9 @@ import java.util.Locale;
public class ToUpperCase {
public static void main(String[] args) {
Locale turkish = new Locale("tr", "TR");
Locale lt = new Locale("lt"); // Lithanian
Locale az = new Locale("az"); // Azeri
Locale turkish = Locale.of("tr", "TR");
Locale lt = Locale.of("lt"); // Lithanian
Locale az = Locale.of("az"); // Azeri
test("\u00DF", turkish, "SS");
test("a\u00DF", turkish, "ASS");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -48,7 +48,7 @@ public class UnicodeCasingTest {
// Locales which are used for testing
private static List<Locale> locales = new ArrayList<>();
static {
locales.add(new Locale("az", ""));
locales.add(Locale.of("az"));
locales.addAll(java.util.Arrays.asList(Locale.getAvailableLocales()));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -42,7 +42,7 @@ public class Turkish {
Locale loc = Locale.getDefault();
try {
Locale.setDefault(new Locale("tr", "TR"));
Locale.setDefault(Locale.of("tr", "TR"));
Provider p2 = new TProvider("T2");
System.out.println(p2.getServices()); // trigger service parsing

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1391,7 +1391,7 @@ public class BreakIteratorTest extends IntlTest
// Confirm changes in BreakIteratorRules_th.java have been reflected.
iter = BreakIterator.getLineInstance(new Locale("th", ""));
iter = BreakIterator.getLineInstance(Locale.of("th"));
/* Thai <Seven(Nd)>
* <Left Double Quotation Mark(Pi)>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -39,7 +39,7 @@ public class NewVSOld_th_TH {
UnsupportedEncodingException,
IOException {
final String ENCODING = "UTF-8";
final Locale THAI_LOCALE = new Locale("th", "TH");
final Locale THAI_LOCALE = Locale.of("th", "TH");
String rawFileName = "test_th_TH.txt";
String oldFileName = "broken_th_TH.txt";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -115,7 +115,7 @@ public class APITest extends CollatorTest {
}
logln("Create junk collation: ");
Locale abcd = new Locale("ab", "CD", "");
Locale abcd = Locale.of("ab", "CD");
Collator junk = null;
try {
junk = Collator.getInstance(abcd);
@ -145,7 +145,7 @@ public class APITest extends CollatorTest {
errln("Default collation creation failed.");
}
Collator col2 = null;
Locale dk = new Locale("da", "DK", "");
Locale dk = Locale.of("da", "DK");
try {
col2 = Collator.getInstance(dk);
} catch (Exception bar) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,8 +32,8 @@ import java.util.Locale;
public class Bug5047314 {
private static Collator colLao = Collator.getInstance(new Locale("lo"));
private static Collator colThai = Collator.getInstance(new Locale("th"));
private static Collator colLao = Collator.getInstance(Locale.of("lo"));
private static Collator colThai = Collator.getInstance(Locale.of("th"));
private static String[] textLao = {
"\u0ec0", "\u0ec1", "\u0ec2", "\u0ec3", "\u0ec4"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -212,5 +212,5 @@ public class DanishTest extends CollatorTest {
}
}
private final Collator myCollation = Collator.getInstance(new Locale("da", "", ""));
private final Collator myCollation = Collator.getInstance(Locale.of("da"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -95,5 +95,5 @@ public class FinnishTest extends CollatorTest {
tertiarySourceData, tertiaryTargetData, tertiaryResults);
}
private final Collator myCollation = Collator.getInstance(new Locale("fi", "FI", ""));
private final Collator myCollation = Collator.getInstance(Locale.of("fi", "FI"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -346,7 +346,7 @@ public class Regression extends CollatorTest {
//
public void Test4087241() {
RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(
new Locale("da", "DK"));
Locale.of("da", "DK"));
c.setStrength(Collator.SECONDARY);
String[] tests = {
@ -375,7 +375,7 @@ public class Regression extends CollatorTest {
// Micro symbol and greek lowercase letter Mu should sort identically
//
public void Test4092260() {
Collator c = Collator.getInstance(new Locale("el", ""));
Collator c = Collator.getInstance(Locale.of("el"));
// will only be equal when FULL_DECOMPOSITION is used
c.setDecomposition(Collator.FULL_DECOMPOSITION);
@ -388,7 +388,7 @@ public class Regression extends CollatorTest {
}
void Test4095316() {
Collator c = Collator.getInstance(new Locale("el", "GR"));
Collator c = Collator.getInstance(Locale.of("el", "GR"));
c.setStrength(Collator.TERTIARY);
// javadocs for RuleBasedCollator clearly specify that characters containing compatability
// chars MUST use FULL_DECOMPOSITION to get accurate comparisons.
@ -544,7 +544,7 @@ public class Regression extends CollatorTest {
// Code pasted straight from the bug report
//
// create spanish locale and collator
Locale l = new Locale("es", "es");
Locale l = Locale.of("es", "es");
Collator col = Collator.getInstance(l);
// this spanish phrase kills it!

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -102,5 +102,5 @@ public class SpanishTest extends CollatorTest {
tertiarySourceData, tertiaryTargetData, tertiaryResults);
}
private final Collator myCollation = Collator.getInstance(new Locale("es", "ES", ""));
private final Collator myCollation = Collator.getInstance(Locale.of("es", "ES"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -153,5 +153,5 @@ public class ThaiTest extends CollatorTest {
primarySourceData, primaryTargetData, primaryResults);
}
private final Collator myCollation = Collator.getInstance(new Locale("th"));
private final Collator myCollation = Collator.getInstance(Locale.of("th"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -115,5 +115,5 @@ public class TurkishTest extends CollatorTest {
tertiarySourceData, tertiaryTargetData, tertiaryResults);
}
private final Collator myCollation = Collator.getInstance(new Locale("tr", "TR", ""));
private final Collator myCollation = Collator.getInstance(Locale.of("tr", "TR"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -361,5 +361,5 @@ public class VietnameseTest extends CollatorTest {
}
}
private final Collator myCollation = Collator.getInstance(new Locale("vi", "VN"));
private final Collator myCollation = Collator.getInstance(Locale.of("vi", "VN"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -43,43 +43,43 @@ import org.testng.annotations.Test;
public class TestCompactNumber {
private static final NumberFormat FORMAT_DZ_LONG = NumberFormat
.getCompactNumberInstance(new Locale("dz"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("dz"), NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_EN_US_SHORT = NumberFormat
.getCompactNumberInstance(Locale.US, NumberFormat.Style.SHORT);
private static final NumberFormat FORMAT_EN_LONG = NumberFormat
.getCompactNumberInstance(new Locale("en"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.ENGLISH, NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_HI_IN_LONG = NumberFormat
.getCompactNumberInstance(new Locale("hi", "IN"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("hi", "IN"), NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_JA_JP_SHORT = NumberFormat
.getCompactNumberInstance(Locale.JAPAN, NumberFormat.Style.SHORT);
private static final NumberFormat FORMAT_IT_SHORT = NumberFormat
.getCompactNumberInstance(new Locale("it"), NumberFormat.Style.SHORT);
.getCompactNumberInstance(Locale.ITALIAN, NumberFormat.Style.SHORT);
private static final NumberFormat FORMAT_CA_LONG = NumberFormat
.getCompactNumberInstance(new Locale("ca"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("ca"), NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_AS_LONG = NumberFormat
.getCompactNumberInstance(new Locale("as"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("as"), NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_BRX_SHORT = NumberFormat
.getCompactNumberInstance(new Locale("brx"), NumberFormat.Style.SHORT);
.getCompactNumberInstance(Locale.of("brx"), NumberFormat.Style.SHORT);
private static final NumberFormat FORMAT_SW_LONG = NumberFormat
.getCompactNumberInstance(new Locale("sw"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("sw"), NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_SE_SHORT = NumberFormat
.getCompactNumberInstance(new Locale("se"), NumberFormat.Style.SHORT);
.getCompactNumberInstance(Locale.of("se"), NumberFormat.Style.SHORT);
private static final NumberFormat FORMAT_DE_LONG = NumberFormat
.getCompactNumberInstance(Locale.GERMAN, NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_SL_LONG = NumberFormat
.getCompactNumberInstance(new Locale("sl"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("sl"), NumberFormat.Style.LONG);
@DataProvider(name = "format")
Object[][] compactFormatData() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -165,10 +165,10 @@ public class TestEquality {
@Test
public void testEqualsAndHashCode() {
NumberFormat cnf1 = NumberFormat
.getCompactNumberInstance(new Locale("hi", "IN"), NumberFormat.Style.SHORT);
.getCompactNumberInstance(Locale.of("hi", "IN"), NumberFormat.Style.SHORT);
cnf1.setMinimumIntegerDigits(5);
NumberFormat cnf2 = NumberFormat
.getCompactNumberInstance(new Locale("hi", "IN"), NumberFormat.Style.SHORT);
.getCompactNumberInstance(Locale.of("hi", "IN"), NumberFormat.Style.SHORT);
cnf2.setMinimumIntegerDigits(5);
if (cnf1.equals(cnf2)) {
if (cnf1.hashCode() != cnf2.hashCode()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -43,7 +43,7 @@ import org.testng.annotations.Test;
public class TestFormatToCharacterIterator {
private static final NumberFormat FORMAT_DZ = NumberFormat
.getCompactNumberInstance(new Locale("dz"),
.getCompactNumberInstance(Locale.of("dz"),
NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_EN_US = NumberFormat
@ -51,7 +51,7 @@ public class TestFormatToCharacterIterator {
NumberFormat.Style.SHORT);
private static final NumberFormat FORMAT_EN_LONG = NumberFormat
.getCompactNumberInstance(new Locale("en"),
.getCompactNumberInstance(Locale.ENGLISH,
NumberFormat.Style.LONG);
@DataProvider(name = "fieldPositions")

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -45,16 +45,16 @@ import org.testng.annotations.Test;
public class TestMutatingInstance {
private static final NumberFormat FORMAT_FRACTION = NumberFormat
.getCompactNumberInstance(new Locale("en"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.ENGLISH, NumberFormat.Style.LONG);
private static final CompactNumberFormat FORMAT_GROUPING = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(new Locale("en"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.ENGLISH, NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_MININTEGER = NumberFormat
.getCompactNumberInstance(new Locale("en"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.ENGLISH, NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_PARSEINTONLY = NumberFormat
.getCompactNumberInstance(new Locale("en"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.ENGLISH, NumberFormat.Style.LONG);
// No compact patterns are specified for this instance except at index 4.
// This is to test how the behaviour differs between compact number formatting

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -41,28 +41,28 @@ import java.util.Locale;
public class TestParseBigDecimal {
private static final CompactNumberFormat FORMAT_DZ_LONG = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(new Locale("dz"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("dz"), NumberFormat.Style.LONG);
private static final CompactNumberFormat FORMAT_EN_US_SHORT = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(Locale.US, NumberFormat.Style.SHORT);
private static final CompactNumberFormat FORMAT_EN_LONG = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(new Locale("en"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.ENGLISH, NumberFormat.Style.LONG);
private static final CompactNumberFormat FORMAT_HI_IN_LONG = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(new Locale("hi", "IN"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("hi", "IN"), NumberFormat.Style.LONG);
private static final CompactNumberFormat FORMAT_JA_JP_SHORT = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(Locale.JAPAN, NumberFormat.Style.SHORT);
private static final CompactNumberFormat FORMAT_IT_SHORT = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(new Locale("it"), NumberFormat.Style.SHORT);
.getCompactNumberInstance(Locale.ITALIAN, NumberFormat.Style.SHORT);
private static final CompactNumberFormat FORMAT_SW_LONG = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(new Locale("sw"), NumberFormat.Style.LONG);
.getCompactNumberInstance(Locale.of("sw"), NumberFormat.Style.LONG);
private static final CompactNumberFormat FORMAT_SE_SHORT = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(new Locale("se"), NumberFormat.Style.SHORT);
.getCompactNumberInstance(Locale.of("se"), NumberFormat.Style.SHORT);
@BeforeTest
public void mutateInstances() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -41,7 +41,7 @@ import org.testng.annotations.Test;
public class TestWithCompatProvider {
private static final NumberFormat FORMAT_DZ_SHORT = NumberFormat
.getCompactNumberInstance(new Locale("dz"), NumberFormat.Style.SHORT);
.getCompactNumberInstance(Locale.of("dz"), NumberFormat.Style.SHORT);
private static final NumberFormat FORMAT_EN_US_SHORT = NumberFormat
.getCompactNumberInstance(Locale.US, NumberFormat.Style.SHORT);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -45,7 +45,7 @@ import static org.testng.Assert.*;
public class TestSerialization {
private static final NumberFormat FORMAT_HI = NumberFormat.getCompactNumberInstance(
new Locale("hi"), NumberFormat.Style.SHORT);
Locale.of("hi"), NumberFormat.Style.SHORT);
private static final CompactNumberFormat FORMAT_EN_US = (CompactNumberFormat) NumberFormat
.getCompactNumberInstance(Locale.US, NumberFormat.Style.LONG);
private static final NumberFormat FORMAT_JA_JP = NumberFormat.getCompactNumberInstance(

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -41,7 +41,7 @@ public class Bug4322313 extends IntlTest {
boolean err = false;
long mpm = 60 * 1000; /* Milliseconds per a minute */
Locale[] locs = {Locale.US, Locale.JAPAN, Locale.UK, new Locale("ar")};
Locale[] locs = {Locale.US, Locale.JAPAN, Locale.UK, Locale.of("ar")};
String[] formats = {
"z",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,7 +34,7 @@ import java.util.*;
public class Bug4823811 {
private static Locale localeEG = new Locale("ar", "EG");
private static Locale localeEG = Locale.of("ar", "EG");
private static Locale localeUS = Locale.US;
private static String JuneInArabic = "\u064a\u0648\u0646\u064a\u0648";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,8 +35,8 @@ public class Bug6683975 {
private static boolean err = false;
private static Locale th = new Locale("th", "");
private static Locale th_TH = new Locale("th", "TH");
private static Locale th = Locale.of("th");
private static Locale th_TH = Locale.of("th", "TH");
private static String expected_th[] = {
"\u0e27\u0e31\u0e19\u0e2d\u0e31\u0e07\u0e04\u0e32\u0e23\u0e17\u0e35\u0e48 30 \u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19 \u0e04.\u0e28. 2008, 8 \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 0 \u0e19\u0e32\u0e17\u0e35 00 \u0e27\u0e34\u0e19\u0e32\u0e17\u0e35", // 0: FULL
"30 \u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19 2008, 8 \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 0 \u0e19\u0e32\u0e17\u0e35", // 1: LONG

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -38,7 +38,7 @@ import java.util.Locale;
public class Bug8139572 {
private static final Locale RUSSIAN = new Locale("ru");
private static final Locale RUSSIAN = Locale.of("ru");
private static final Date SEPT12 = new GregorianCalendar(2015, Calendar.SEPTEMBER, 12).getTime();
private static final String[] PATTERNS = {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,7 @@ import java.text.*;
import java.util.*;
public class ContextMonthNamesTest {
static Locale CZECH = new Locale("cs");
static Locale CZECH = Locale.of("cs");
static Date JAN30 = new GregorianCalendar(2012, Calendar.JANUARY, 30).getTime();
static String[] PATTERNS = {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -265,7 +265,7 @@ public class DateFormatRegression extends IntlTest {
Locale saveLocale = Locale.getDefault();
TimeZone saveZone = TimeZone.getDefault();
try {
Locale curLocale = new Locale("de","DE");
Locale curLocale = Locale.GERMANY;
Locale.setDefault(curLocale);
TimeZone.setDefault(TimeZone.getTimeZone("EST"));
curDate = new Date(98, 0, 1);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -78,7 +78,7 @@ public class DateFormatRoundTripTest extends IntlTest {
}
/**
* Parse a name like "fr_FR" into new Locale("fr", "FR", "");
* Parse a name like "fr_FR" into Locale.of("fr", "FR", "");
*/
static Locale createLocale(String name) {
String country = "",
@ -92,7 +92,7 @@ public class DateFormatRoundTripTest extends IntlTest {
variant = country.substring(i+1);
country = country.substring(0, i);
}
return new Locale(name, country, variant);
return Locale.of(name, country, variant);
}
public static void main(String[] args) throws Exception {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -413,7 +413,7 @@ public class DateFormatTest extends IntlTest
public void TestCzechMonths459()
{
// Use Czech, which has month names with shared prefixes for June and July
DateFormat fmt = DateFormat.getDateInstance(DateFormat.FULL, new Locale("cs", "", ""));
DateFormat fmt = DateFormat.getDateInstance(DateFormat.FULL, Locale.of("cs"));
//((SimpleDateFormat)fmt).applyPattern("MMMM d yyyy");
logln("Pattern " + ((SimpleDateFormat)fmt).toPattern());
@ -988,7 +988,7 @@ test commented out pending API-change approval
*/
public void TestBuddhistEraBugId4469904() {
String era = "\u0e1e.\u0e28.";
Locale loc = new Locale("th", "TH");
Locale loc = Locale.of("th", "TH");
Calendar cal = Calendar.getInstance(Locale.US);
cal.set(2001, 7, 23);
Date date = cal.getTime();
@ -1208,7 +1208,7 @@ test commented out pending API-change approval
}
public void Test8216969() throws Exception {
Locale locale = new Locale("ru");
Locale locale = Locale.of("ru");
String format = "\u0434\u0435\u043a";
String standalone = "\u0434\u0435\u043a.";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -60,5 +60,5 @@ public class LocaleDateFormats {
};
}
// en_SG Locale instance
private static final Locale localeEnSG = new Locale("en", "SG");
private static final Locale localeEnSG = Locale.of("en", "SG");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -128,7 +128,7 @@ public class NonGregorianFormatTest {
Locale.setDefault(locale);
// Tests with the Japanese imperial calendar
Locale calendarLocale = new Locale("ja", "JP", "JP");
Locale calendarLocale = Locale.of("ja", "JP", "JP");
testRoundTrip(calendarLocale);
testRoundTripSimple(calendarLocale,
locale == Locale.ENGLISH ? JAPANESE_EN : JAPANESE_JA);
@ -136,7 +136,7 @@ public class NonGregorianFormatTest {
locale == Locale.ENGLISH ? EXCEPTION_JAPANESE_EN : EXCEPTION_JAPANESE_JA);
// Tests with the Thai Buddhist calendar
calendarLocale = new Locale("th", "TH");
calendarLocale = Locale.of("th", "TH");
testRoundTrip(calendarLocale);
testRoundTripSimple(calendarLocale,
locale == Locale.ENGLISH ? BUDDHIST_EN : BUDDHIST_JA);

View File

@ -45,7 +45,7 @@ import java.util.Locale;
public class TestDayPeriodWithSDF {
private static final Locale BURMESE = new Locale("my");
private static final Locale BURMESE = Locale.of("my");
private static final DateFormat FORMAT_SHORT_BURMESE = DateFormat.getTimeInstance(DateFormat.SHORT, BURMESE);
private static final DateFormat FORMAT_MEDIUM_BURMESE = DateFormat.getTimeInstance(DateFormat.MEDIUM, BURMESE);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -135,7 +135,7 @@ public class WeekDateTest {
private static void noWeekDateSupport() throws Exception {
// Tests with Japanese Imperial Calendar that doesn't support week dates.
Calendar jcal = Calendar.getInstance(TimeZone.getTimeZone("GMT"),
new Locale("ja", "JP", "JP"));
Locale.of("ja", "JP", "JP"));
String format = "2-W01-2"; // 2019-12-31 == R1-12-31
int expectedYear = 2019;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -56,7 +56,7 @@ public class bug4358730 extends IntlTest {
try {
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
Locale.setDefault(new Locale("en", "US"));
Locale.setDefault(Locale.US);
SimpleDateFormat sdf = new SimpleDateFormat();
for (int i = 0; i < datasize; i++) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -58,12 +58,12 @@ class GoldenDoubleValues {
// TestLocale is the testing locale used by RoundingAndPropertyTest test,
// when testing the golden double values
static final Locale TestLocale = new Locale("en", "US");
static final Locale TestLocale = Locale.US;
// FullTestLocale is the testing locale used by RoundingAndPropertyTest test,
// when testing full localization of double values.
static final Locale FullLocalizationTestLocale = new Locale("hi", "IN");
static final Locale FullLocalizationTestLocale = Locale.of("hi", "IN");
/* Below are the two double values used for exercising the changes of

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -704,7 +704,7 @@ public class RoundingAndPropertyTest {
System.out.print("Checking " + propertyName + " property.");
DecimalFormatSymbols initialDecimalFormatSymbols = df.getDecimalFormatSymbols();
firstFormatResult = df.format(d1);
Locale bizarreLocale = new Locale("fr", "FR");
Locale bizarreLocale = Locale.FRANCE;
DecimalFormatSymbols unusualSymbols = new DecimalFormatSymbols(bizarreLocale);
unusualSymbols.setDecimalSeparator('@');
unusualSymbols.setGroupingSeparator('|');

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,7 @@ import java.util.*;
public class Bug8132125 {
public static void main(String[] args) {
Locale deCH = new Locale("de", "CH");
Locale deCH = Locale.of("de", "CH");
NumberFormat nf = NumberFormat.getInstance(deCH);
String expected = "54\u2019839\u2019483.142"; // i.e. "\u2019" as decimal separator, "\u2019" as grouping separator

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -58,7 +58,7 @@ public class CurrencyFormat {
Locale.JAPAN,
Locale.GERMANY,
Locale.ITALY,
new Locale("it", "IT", "EURO"),
Locale.of("it", "IT", "EURO"),
Locale.forLanguageTag("de-AT"),
Locale.forLanguageTag("fr-CH"),
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,9 +34,9 @@ import java.util.*;
public class MultipleNumberScriptTest {
static Locale[] locales = {
new Locale("ar"),
new Locale("ar", "EG"),
new Locale("ar", "DZ"),
Locale.of("ar"),
Locale.of("ar", "EG"),
Locale.of("ar", "DZ"),
Locale.forLanguageTag("ar-EG-u-nu-arab"),
Locale.forLanguageTag("ar-EG-u-nu-latn"),
Locale.forLanguageTag("ar-DZ-u-nu-arab"),
@ -44,7 +44,7 @@ public class MultipleNumberScriptTest {
Locale.forLanguageTag("ee"),
Locale.forLanguageTag("ee-GH"),
Locale.forLanguageTag("ee-GH-u-nu-latn"),
new Locale("th", "TH", "TH"),
Locale.of("th", "TH", "TH"),
Locale.forLanguageTag("th-TH"),
Locale.forLanguageTag("th-TH-u-nu-thai"),
Locale.forLanguageTag("th-TH-u-nu-hoge"),

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -487,7 +487,7 @@ public class NumberRegression extends IntlTest {
* interpreted as monetary separator if currency symbol is seen!
*/
public void Test4087244 () {
Locale de = new Locale("pt", "PT");
Locale de = Locale.of("pt", "PT");
DecimalFormat df = (DecimalFormat) NumberFormat.getCurrencyInstance(de);
DecimalFormatSymbols sym = df.getDecimalFormatSymbols();
sym.setMonetaryDecimalSeparator('$');

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -37,7 +37,7 @@ public class TestPeruCurrencyFormat {
public static void main(String[] args) {
final String expected = "S/.1,234.56";
NumberFormat currencyFmt =
NumberFormat.getCurrencyInstance(new Locale("es", "PE"));
NumberFormat.getCurrencyInstance(Locale.of("es", "PE"));
String s = currencyFmt.format(1234.56);
if (!s.equals(expected)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -55,25 +55,25 @@ public class Bug6215962 {
mf2 = new MessageFormat("{0}", Locale.JAPAN);
check(mf1, mf2, false);
mf1 = new MessageFormat("{0}", new Locale("ja", "JP"));
mf1 = new MessageFormat("{0}", Locale.of("ja", "JP"));
check(mf1, mf2, true);
mf1.setLocale(null);
check(mf1, mf2, false);
mf1 = new MessageFormat("{0}", new Locale("ja", "JP", "FOO"));
mf1 = new MessageFormat("{0}", Locale.of("ja", "JP", "FOO"));
check(mf1, mf2, false);
mf2 = new MessageFormat("{1}", new Locale("ja", "JP", "FOO"));
mf2 = new MessageFormat("{1}", Locale.of("ja", "JP", "FOO"));
check(mf1, mf2, false);
mf1 = new MessageFormat("{1}", new Locale("ja", "JP", "FOO"));
mf1 = new MessageFormat("{1}", Locale.of("ja", "JP", "FOO"));
check(mf1, mf2, true);
mf1 = new MessageFormat("{1, date}", new Locale("ja", "JP", "FOO"));
mf1 = new MessageFormat("{1, date}", Locale.of("ja", "JP", "FOO"));
check(mf1, mf2, false);
mf2 = new MessageFormat("{1, date}", new Locale("ja", "JP", "FOO"));
mf2 = new MessageFormat("{1, date}", Locale.of("ja", "JP", "FOO"));
check(mf1, mf2, true);
}

View File

@ -1,5 +1,5 @@
/*
o Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
o Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -151,21 +151,21 @@ public class TCKJapaneseChronology {
@Test
public void test_chrono_byLocale_oldJP_noVariant() {
Chronology test = Chronology.ofLocale(new Locale("ja", "JP"));
Chronology test = Chronology.ofLocale(Locale.JAPAN);
Assert.assertEquals(test.getId(), "ISO");
Assert.assertEquals(test, IsoChronology.INSTANCE);
}
@Test
public void test_chrono_byLocale_oldJP_variant() {
Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP"));
Chronology test = Chronology.ofLocale(Locale.of("ja", "JP", "JP"));
Assert.assertEquals(test.getId(), "Japanese");
Assert.assertEquals(test, JapaneseChronology.INSTANCE);
}
@Test
public void test_chrono_byLocale_iso() {
Assert.assertEquals(Chronology.ofLocale(new Locale("ja", "JP")).getId(), "ISO");
Assert.assertEquals(Chronology.ofLocale(Locale.JAPAN).getId(), "ISO");
Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP")).getId(), "ISO");
Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP-JP")).getId(), "ISO");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -140,21 +140,21 @@ public class TCKThaiBuddhistChronology {
@Test
public void test_chrono_byLocale_oldTH_noVariant() { // deliberately different to Calendar
Chronology test = Chronology.ofLocale(new Locale("th", "TH"));
Chronology test = Chronology.ofLocale(Locale.of("th", "TH"));
Assert.assertEquals(test.getId(), "ISO");
Assert.assertEquals(test, IsoChronology.INSTANCE);
}
@Test
public void test_chrono_byLocale_oldTH_variant() {
Chronology test = Chronology.ofLocale(new Locale("th", "TH", "TH"));
Chronology test = Chronology.ofLocale(Locale.of("th", "TH", "TH"));
Assert.assertEquals(test.getId(), "ISO");
Assert.assertEquals(test, IsoChronology.INSTANCE);
}
@Test
public void test_chrono_byLocale_iso() {
Assert.assertEquals(Chronology.ofLocale(new Locale("th", "TH")).getId(), "ISO");
Assert.assertEquals(Chronology.ofLocale(Locale.of("th", "TH")).getId(), "ISO");
Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("th-TH")).getId(), "ISO");
Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("th-TH-TH")).getId(), "ISO");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -79,7 +79,7 @@ import org.testng.annotations.Test;
@Test
public class TestDateTimeTextProvider extends AbstractTestPrinterParser {
Locale enUS = new Locale("en", "US");
Locale enUS = Locale.US;
//-----------------------------------------------------------------------
@DataProvider(name = "Text")

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -86,8 +86,8 @@ import org.testng.annotations.Test;
@Test
public class TestDateTimeTextProviderWithLocale extends AbstractTestPrinterParser {
Locale enUS = new Locale("en", "US");
Locale ptBR = new Locale("pt", "BR");
Locale enUS = Locale.US;
Locale ptBR = Locale.of("pt", "BR");
//-----------------------------------------------------------------------
@DataProvider(name = "Text")

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -45,7 +45,7 @@ import java.util.Locale;
@Test
public class TestDayPeriodWithDTF {
private static final Locale BURMESE = new Locale("my");
private static final Locale BURMESE = Locale.of("my");
private static final DateTimeFormatter FORMAT_SHORT_BURMESE = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).withLocale(BURMESE);
private static final DateTimeFormatter FORMAT_MEDIUM_BURMESE = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM).withLocale(BURMESE);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -58,7 +58,7 @@ public class TestLocalizedOffsetPrinterParser {
private static final LocalDateTime DT_2012_06_30_12_30_40 = LocalDateTime.of(2012, 6, 30, 12, 30, 40);
private static final Locale LOCALE_GA = new Locale("ga");
private static final Locale LOCALE_GA = Locale.of("ga");
@DataProvider(name="print_localized_custom_locale")
Object[][] data_print_localized_custom_locale() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -53,7 +53,7 @@ public class TestNarrowMonthNamesAndDayNames {
private static final List<Locale> LOCARR = Arrays.asList(Locale.US,
Locale.GERMANY,
Locale.FRANCE,
new Locale("no", "NO"));
Locale.of("no", "NO"));
/**
* Locale en_US, de_DE, fr_FR, no_NO will have same Narrow and
@ -106,7 +106,7 @@ public class TestNarrowMonthNamesAndDayNames {
{Locale.US, new String[]{"M", "T", "W", "T", "F", "S", "S"}},
{Locale.GERMANY, new String[]{"M", "D", "M", "D", "F", "S", "S"}},
{Locale.FRANCE, new String[]{"L", "M", "M", "J", "V", "S", "D"}},
{new Locale("no", "NO"), new String[]{"M", "T", "O", "T", "F", "L", "S"}},};
{Locale.of("no", "NO"), new String[]{"M", "T", "O", "T", "F", "L", "S"}},};
}
//-----------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -71,8 +71,8 @@ public class TestNonIsoFormatter {
private static final LocalDate IsoDate = LocalDate.of(2013, 2, 11);
private static final Locale ARABIC = new Locale("ar");
private static final Locale thTH = new Locale("th", "TH");
private static final Locale ARABIC = Locale.of("ar");
private static final Locale thTH = Locale.of("th", "TH");
private static final Locale thTHTH = Locale.forLanguageTag("th-TH-u-nu-thai");
private static final Locale jaJPJP = Locale.forLanguageTag("ja-JP-u-ca-japanese");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -95,8 +95,8 @@ import static org.testng.Assert.assertEquals;
*/
@Test
public class TestTextParserWithLocale extends AbstractTestPrinterParser {
static final Locale RUSSIAN = new Locale("ru");
static final Locale FINNISH = new Locale("fi");
static final Locale RUSSIAN = Locale.of("ru");
static final Locale FINNISH = Locale.of("fi");
@DataProvider(name="parseDayOfWeekText")
Object[][] providerDayOfWeekData() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -90,8 +90,8 @@ import test.java.time.temporal.MockFieldValue;
*/
@Test
public class TestTextPrinterWithLocale extends AbstractTestPrinterParser {
static final Locale RUSSIAN = new Locale("ru");
static final Locale FINNISH = new Locale("fi");
static final Locale RUSSIAN = Locale.of("ru");
static final Locale FINNISH = Locale.of("fi");
//-----------------------------------------------------------------------
@DataProvider(name="print_DayOfWeekData")

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,7 +34,7 @@ import static java.util.Calendar.*;
public class BuddhistCalendarTest {
private static final Locale THAI_LOCALE = new Locale("th", "TH");
private static final Locale THAI_LOCALE = Locale.of("th", "TH");
public static void main(String[] args) {
testAddRoll();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,7 +34,7 @@ import java.util.Locale;
public class Bug4302966 {
public static void main(String[] args) {
Calendar czechCalendar = Calendar.getInstance(new Locale("cs", "CZ"));
Calendar czechCalendar = Calendar.getInstance(Locale.of("cs", "CZ"));
int firstDayOfWeek = czechCalendar.getFirstDayOfWeek();
if (firstDayOfWeek != Calendar.MONDAY) {
throw new RuntimeException();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,7 @@ import static java.util.Calendar.*;
public class Bug6448234 {
public static void main(String[] args) {
Calendar jcal = Calendar.getInstance(new Locale("ja", "JP", "JP"));
Calendar jcal = Calendar.getInstance(Locale.of("ja", "JP", "JP"));
Calendar gcal = Calendar.getInstance(Locale.US);
for (int i = SUNDAY; i <= SATURDAY; i++) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -83,8 +83,8 @@ public class Bug8167273 {
public static void testEraName() {
Set<Locale> allLocales = Set.of(Locale.getAvailableLocales());
Set<Locale> JpThlocales = Set.of(
new Locale("th", "TH"), Locale.forLanguageTag("th-Thai-TH"),
new Locale("ja", "JP", "JP"), new Locale("th", "TH", "TH")
Locale.of("th", "TH"), Locale.forLanguageTag("th-Thai-TH"),
Locale.of("ja", "JP", "JP"), Locale.of("th", "TH", "TH")
);
Set<Locale> allLocs = new HashSet<>(allLocales);
// Removing Japanese and Thai Locales to check Gregorian Calendar Locales

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,8 +32,8 @@ import java.util.*;
import static java.util.Calendar.*;
public class BuilderTest {
private static final Locale jaJPJP = new Locale("ja", "JP", "JP");
private static final Locale thTH = new Locale("th", "TH");
private static final Locale jaJPJP = Locale.of("ja", "JP", "JP");
private static final Locale thTH = Locale.of("th", "TH");
private static final TimeZone LA = TimeZone.getTimeZone("America/Los_Angeles");
private static final TimeZone TOKYO = TimeZone.getTimeZone("Asia/Tokyo");
private static int error;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -60,7 +60,7 @@ public class CalendarDataTest {
public static void main(String... args) throws Exception {
// world
Calendar cal = Calendar.getInstance(new Locale("", "001"));
Calendar cal = Calendar.getInstance(Locale.of("", "001"));
checkResult("001",
cal.getFirstDayOfWeek(),
cal.getMinimalDaysInFirstWeek());
@ -71,7 +71,7 @@ public class CalendarDataTest {
IntStream.range(0x41, 0x5b)
.mapToObj(c2 -> String.valueOf((char)c1) + String.valueOf((char)c2))
.forEach(region -> {
Calendar c = Calendar.getInstance(new Locale("", region));
Calendar c = Calendar.getInstance(Locale.of("", region));
checkResult(region,
c.getFirstDayOfWeek(),
c.getMinimalDaysInFirstWeek());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -2255,7 +2255,7 @@ public class CalendarRegression extends IntlTest {
errln("equals threw IllegalArugumentException with non-lenient");
}
cal1 = Calendar.getInstance(new Locale("th", "TH"));
cal1 = Calendar.getInstance(Locale.of("th", "TH"));
cal1.setTimeInMillis(0L);
cal2 = Calendar.getInstance(Locale.US);
cal2.setTimeInMillis(0L);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -974,7 +974,7 @@ public class CalendarTest extends IntlTest {
try {
for (int j = 0; j < lt.length; j++) {
Locale l = new Locale(lt[j][0], lt[j][1]);
Locale l = Locale.of(lt[j][0], lt[j][1]);
TimeZone z = TimeZone.getTimeZone(lt[j][2]);
Locale.setDefault(l);
TimeZone.setDefault(z);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -111,7 +111,7 @@ public class CalendarTestEngine {
var = sc.next();
}
}
locale = new Locale(lang, country, var);
locale = Locale.of(lang, country, var);
}
break;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -38,9 +38,9 @@ public class CalendarTypeTest {
static Locale[] locales = new Locale[] {
Locale.US,
Locale.forLanguageTag("th-TH-u-ca-gregory"),
new Locale("th", "TH"),
Locale.of("th", "TH"),
Locale.forLanguageTag("en-US-u-ca-buddhist"),
new Locale("ja", "JP", "JP"),
Locale.of("ja", "JP", "JP"),
Locale.forLanguageTag("en-US-u-ca-japanese")};
static final String[] TYPES = new String[] {
"gregory",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,7 +36,7 @@ import static java.util.Calendar.*;
import sun.util.locale.provider.*;
public class CldrFormatNamesTest {
private static final Locale ARABIC = new Locale("ar");
private static final Locale ARABIC = Locale.of("ar");
private static final Locale ZH_HANT = Locale.forLanguageTag("zh-Hant");
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -69,10 +69,10 @@ public class JapanEraNameCompatTest {
{ KOREAN, KoreanName, "R" },
{ CHINA, CJName, "R" },
{ TAIWAN, CJName, "R" }, // fallback to zh
{ new Locale("ar"), ArabicName, ArabicName },
{ new Locale("th"), ThaiName, "R" },
{ Locale.of("ar"), ArabicName, ArabicName },
{ Locale.of("th"), ThaiName, "R" },
// hi_IN fallback to root
{ new Locale("hi", "IN"), EngName, "R" }
{ Locale.of("hi", "IN"), EngName, "R" }
};
}
@ -91,20 +91,20 @@ public class JapanEraNameCompatTest {
{ KOREAN, KoreanName, KoreanName },
{ CHINA, CJName, CJName },
{ TAIWAN, CJName, CJName },
{ new Locale("ar"), ArabicName, ArabicName },
{ new Locale("th"), ThaiName, ThaiName },
{ new Locale("hi", "IN"), HindiName, HindiName },
{ new Locale("ru"), RussianName, RussianName },
{ new Locale("sr"), SerbianName, SerbianName },
{ Locale.of("ar"), ArabicName, ArabicName },
{ Locale.of("th"), ThaiName, ThaiName },
{ Locale.of("hi", "IN"), HindiName, HindiName },
{ Locale.of("ru"), RussianName, RussianName },
{ Locale.of("sr"), SerbianName, SerbianName },
{ Locale.forLanguageTag("sr-Latn"), SerbLatinName, SerbLatinName },
{ new Locale("hr"), EngName, EngName },
{ new Locale("in"), EngName, EngName },
{ new Locale("lt"), EngName, EngName },
{ new Locale("nl"), EngName, EngName },
{ new Locale("no"), EngName, "R" },
{ new Locale("sv"), EngName, EngName },
{ Locale.of("hr"), EngName, EngName },
{ Locale.of("in"), EngName, EngName },
{ Locale.of("lt"), EngName, EngName },
{ Locale.of("nl"), EngName, EngName },
{ Locale.of("no"), EngName, "R" },
{ Locale.of("sv"), EngName, EngName },
// el fallback to root
{ new Locale("el"), EngName, EngName }
{ Locale.of("el"), EngName, EngName }
};
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,8 +44,8 @@ import static java.util.GregorianCalendar.*;
public class NarrowNamesTest {
private static final Locale US = Locale.US;
private static final Locale JAJPJP = new Locale("ja", "JP", "JP");
private static final Locale THTH = new Locale("th", "TH");
private static final Locale JAJPJP = Locale.of("ja", "JP", "JP");
private static final Locale THTH = Locale.of("th", "TH");
private static final String RESET_INDEX = "RESET_INDEX";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -87,8 +87,8 @@ public class ZoneOffsets {
private static Locale[] locales = {
Locale.getDefault(),
new Locale("th", "TH"),
new Locale("ja", "JP", "JP")};
Locale.of("th", "TH"),
Locale.of("ja", "JP", "JP")};
private static final int HOUR = 60 * 60 * 1000;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -49,7 +49,7 @@ public class Bug4512215 {
private static void testCountryCurrency(String country, String currencyCode,
int digits) {
testCurrencyDefined(currencyCode, digits);
Currency currency = Currency.getInstance(new Locale("", country));
Currency currency = Currency.getInstance(Locale.of("", country));
if (!currency.getCurrencyCode().equals(currencyCode)) {
throw new RuntimeException("[" + country
+ "] expected: " + currencyCode

View File

@ -166,7 +166,7 @@ public class CurrencyTest {
// check an invalid country code
boolean gotException = false;
try {
Currency.getInstance(new Locale("", "EU"));
Currency.getInstance(Locale.of("", "EU"));
} catch (IllegalArgumentException e) {
gotException = true;
}
@ -176,7 +176,7 @@ public class CurrencyTest {
}
static void checkCountryCurrency(String countryCode, String expected) {
Locale locale = new Locale("", countryCode);
Locale locale = Locale.of("", countryCode);
Currency currency = Currency.getInstance(locale);
String code = (currency != null) ? currency.getCurrencyCode() : null;
if (!(expected == null ? code == null : expected.equals(code))) {
@ -257,11 +257,11 @@ public class CurrencyTest {
testDisplayName("USD", Locale.ENGLISH, "US Dollar");
testDisplayName("FRF", Locale.FRENCH, "franc fran\u00e7ais");
testDisplayName("DEM", Locale.GERMAN, "Deutsche Mark");
testDisplayName("ESP", new Locale("es"), "peseta espa\u00f1ola");
testDisplayName("ITL", new Locale("it"), "lira italiana");
testDisplayName("ESP", Locale.of("es"), "peseta espa\u00f1ola");
testDisplayName("ITL", Locale.ITALIAN, "lira italiana");
testDisplayName("JPY", Locale.JAPANESE, "\u65e5\u672c\u5186");
testDisplayName("KRW", Locale.KOREAN, "\ub300\ud55c\ubbfc\uad6d \uc6d0");
testDisplayName("SEK", new Locale("sv"), "svensk krona");
testDisplayName("SEK", Locale.of("sv"), "svensk krona");
testDisplayName("CNY", Locale.SIMPLIFIED_CHINESE, "\u4eba\u6c11\u5e01");
testDisplayName("TWD", Locale.TRADITIONAL_CHINESE, "\u65b0\u53f0\u5e63");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -60,7 +60,7 @@ public class PropertiesTest {
for (char c2 = 'A'; c2 <= 'Z'; c2++) {
String ctry = new StringBuilder().append(c1).append(c2).toString();
try {
Currency c = Currency.getInstance(new Locale("", ctry));
Currency c = Currency.getInstance(Locale.of("", ctry));
if (c != null) {
pw.printf(Locale.ROOT, "%s=%s,%03d,%1d\n",
ctry,
@ -195,7 +195,7 @@ public class PropertiesTest {
private static void bug7102969() {
// check the correct overriding of special case entries
Currency cur = Currency.getInstance(new Locale("", "JP"));
Currency cur = Currency.getInstance(Locale.of("", "JP"));
if (!cur.getCurrencyCode().equals("ABC")) {
throw new RuntimeException("[Expected: ABC as currency code of JP, found: "
+ cur.getCurrencyCode() + "]");

View File

@ -199,7 +199,7 @@ public class ValidateISO4217 {
}
testCurrencyDefined(currencyCode, numericCode, digits);
Locale loc = new Locale("", country);
Locale loc = Locale.of("", country);
try {
Currency currency = Currency.getInstance(loc);
if (!currency.getCurrencyCode().equals(currencyCode)) {
@ -257,7 +257,7 @@ public class ValidateISO4217 {
if (codes[toIndex(country)] == UNDEFINED) {
ex = false;
try {
Currency.getInstance(new Locale("", country));
Currency.getInstance(Locale.of("", country));
}
catch (IllegalArgumentException e) {
ex = true;
@ -270,7 +270,7 @@ public class ValidateISO4217 {
} else if (codes[toIndex(country)] == SKIPPED) {
Currency cur = null;
try {
cur = Currency.getInstance(new Locale("", country));
cur = Currency.getInstance(Locale.of("", country));
}
catch (Exception e) {
System.err.println("Error: " + e + ": Country=" +

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -46,7 +46,7 @@ import java.util.stream.IntStream;
public class FormatLocale {
static final Locale TURKISH = new Locale("tr");
static final Locale TURKISH = Locale.of("tr");
static final List<String> conversions = List.of(
"%S",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -46,7 +46,7 @@ public class FormatterWithProvider {
try {
testFormatter(Locale.JAPANESE, formatString, number);
testFormatter(Locale.FRENCH, formatString, number);
testFormatter(new Locale("hi", "IN"), formatString, number);
testFormatter(Locale.of("hi", "IN"), formatString, number);
} catch (ClassCastException ex) {
throw new RuntimeException("[FAILED: A ClassCastException is" +

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -37,7 +37,7 @@ import java.util.Locale;
public class NoGroupingUsed {
public static void main(String[] args) {
Locale locale = new Locale("xx", "YY");
Locale locale = Locale.of("xx", "YY");
String number = "1234567";
String formatString = "%,d";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import java.util.Locale;
public class NumberFormatProviderImpl extends NumberFormatProvider {
private static final Locale[] locales = {Locale.FRENCH, Locale.JAPANESE,
new Locale("hi", "IN"), new Locale("xx", "YY")};
Locale.of("hi", "IN"), Locale.of("xx", "YY")};
@Override
public NumberFormat getCurrencyInstance(Locale locale) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -60,7 +60,7 @@ public class Bug4175998Test extends IntlTest {
boolean bad = false;
for (int i = 0; i < CODES.length; i++) {
final String[] localeCodes = CODES[i];
final Locale l = new Locale(localeCodes[0], "");
final Locale l = Locale.of(localeCodes[0]);
final String iso3 = l.getISO3Language();
if (!iso3.equals(localeCodes[1]) /*&& !iso3.equals(localeCodes[2])*/) {
logln("Locale("+l+") returned bad ISO3 language code."

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -84,7 +84,7 @@ public class Bug4184873Test extends IntlTest {
ObjectInputStream in = getStream(lang);
if (in != null) {
final Locale loc = (Locale)in.readObject();
final Locale expected = new Locale(lang, "XX");
final Locale expected = Locale.of(lang, "XX");
if (!(expected.equals(loc))) {
errln("Locale didn't maintain invariants for: "+lang);
errln(" got: "+loc);
@ -123,7 +123,7 @@ public class Bug4184873Test extends IntlTest {
try {
ObjectOutputStream out = new ObjectOutputStream(
new FileOutputStream("Bug4184873_"+lang));
out.writeObject(new Locale(lang, "XX"));
out.writeObject(Locale.of(lang, "XX"));
out.close();
} catch (Exception e) {
System.out.println(e);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,7 +36,7 @@ public class Bug4210525 {
String country = "US";
String variant = "socal";
Locale aLocale = new Locale(language, country, variant);
Locale aLocale = Locale.of(language, country, variant);
String localeVariant = aLocale.getVariant();
if (localeVariant.equals(variant)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,7 @@ public class Bug4316602 {
public static void main(String[] args) throws Exception {
String language = "ja";
Locale aLocale = new Locale(language);
Locale aLocale = Locale.of(language);
if (aLocale.toString().equals(language)) {
System.out.println("passed");
} else {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,7 @@ public class Bug4518797 {
if (args.length == 1) {
duration = Math.max(5, Integer.parseInt(args[0]));
}
final Locale loc = new Locale("ja", "US");
final Locale loc = Locale.of("ja", "US");
final int hashcode = loc.hashCode();
System.out.println("correct hash code: " + hashcode);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -62,7 +62,7 @@ public class Bug8135061 {
* return "nv" as the matching tag
*/
ranges = LanguageRange.parse("i-navajo");
locales = Collections.singleton(new Locale("nv"));
locales = Collections.singleton(Locale.of("nv"));
try {
Locale match = Locale.lookup(ranges, locales);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -87,7 +87,7 @@ public class Bug8154797 {
public static void main(String args[]) {
Bug8154797.generateExpectedValues();
Locale[] locArr = {new Locale("hi", "IN"), Locale.UK, new Locale("fi", "FI"),
Locale[] locArr = {Locale.of("hi", "IN"), Locale.UK, Locale.of("fi", "FI"),
Locale.ROOT, Locale.GERMAN, Locale.JAPANESE,
Locale.ENGLISH, Locale.FRANCE};
for (Locale loc : locArr) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -56,7 +56,7 @@ public class Bug8159420 {
try {
origLocale = Locale.getDefault();
Locale.setDefault(new Locale("tr", "TR"));
Locale.setDefault(Locale.of("tr", "TR"));
testParse();
testFilter(EXTENDED_FILTERING);
testFilter(AUTOSELECT_FILTERING);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import java.util.*;
public class ExtensionsTest {
public static void main(String[] args) {
Locale jaJPJP = new Locale("ja", "JP", "JP");
Locale jaJPJP = Locale.of("ja", "JP", "JP");
if (!jaJPJP.hasExtensions()) {
error(jaJPJP + " should have an extension.");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -46,7 +46,7 @@ public class GenerateKeyList {
Locale[] availableLocales = Locale.getAvailableLocales();
ResourceBundle bundle = ResourceBundle.getBundle(packageName +
resourceBundleName, new Locale("", "", ""));
resourceBundleName, Locale.of(""));
dumpResourceBundle(resourceBundleName + "/", bundle, out);
for (int i = 0; i < availableLocales.length; i++) {
bundle = ResourceBundle.getBundle(packageName + resourceBundleName,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -69,26 +69,26 @@ public class InternationalBAT {
// http://webwork.eng/j2se/1.4/docs/guide/intl/locale.doc.html#util-text
private static Locale[] requiredLocales = {
new Locale("ar", "SA"),
new Locale("zh", "CN"),
new Locale("zh", "TW"),
new Locale("nl", "NL"),
new Locale("en", "AU"),
new Locale("en", "CA"),
new Locale("en", "GB"),
new Locale("en", "US"),
new Locale("fr", "CA"),
new Locale("fr", "FR"),
new Locale("de", "DE"),
new Locale("iw", "IL"),
new Locale("hi", "IN"),
new Locale("it", "IT"),
new Locale("ja", "JP"),
new Locale("ko", "KR"),
new Locale("pt", "BR"),
new Locale("es", "ES"),
new Locale("sv", "SE"),
new Locale("th", "TH"),
Locale.of("ar", "SA"),
Locale.CHINA,
Locale.TAIWAN,
Locale.of("nl", "NL"),
Locale.of("en", "AU"),
Locale.of("en", "CA"),
Locale.UK,
Locale.US,
Locale.of("fr", "CA"),
Locale.FRANCE,
Locale.GERMANY,
Locale.of("iw", "IL"),
Locale.of("hi", "IN"),
Locale.ITALY,
Locale.JAPAN,
Locale.KOREA,
Locale.of("pt", "BR"),
Locale.of("es", "ES"),
Locale.of("sv", "SE"),
Locale.of("th", "TH"),
};
// Date strings for May 10, 2001, for the required locales
@ -181,26 +181,26 @@ public class InternationalBAT {
// one sample locale each for the required encodings
private static Locale[] sampleLocales = {
new Locale("ar", "SA"),
new Locale("zh", "CN"),
new Locale("zh", "TW"),
new Locale("iw", "IL"),
new Locale("ja", "JP"),
new Locale("ko", "KR"),
new Locale("it", "IT"),
new Locale("th", "TH"),
new Locale("ar", "SA"),
new Locale("zh", "CN"),
new Locale("zh", "CN"),
new Locale("zh", "CN"),
new Locale("zh", "TW"),
new Locale("iw", "IL"),
new Locale("ja", "JP"),
new Locale("ja", "JP"),
new Locale("ko", "KR"),
new Locale("it", "IT"),
new Locale("it", "IT"),
new Locale("th", "TH"),
Locale.of("ar", "SA"),
Locale.of("zh", "CN"),
Locale.of("zh", "TW"),
Locale.of("iw", "IL"),
Locale.of("ja", "JP"),
Locale.of("ko", "KR"),
Locale.of("it", "IT"),
Locale.of("th", "TH"),
Locale.of("ar", "SA"),
Locale.of("zh", "CN"),
Locale.of("zh", "CN"),
Locale.of("zh", "CN"),
Locale.of("zh", "TW"),
Locale.of("iw", "IL"),
Locale.of("ja", "JP"),
Locale.of("ja", "JP"),
Locale.of("ko", "KR"),
Locale.of("it", "IT"),
Locale.of("it", "IT"),
Locale.of("th", "TH"),
};
// expected conversion results for the date strings of the sample locales

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -309,7 +309,7 @@ public class LocaleEnhanceTest extends IntlTest {
for (int i = 0; i < tests.length; ++ i) {
String[] test = tests[i];
String id = String.valueOf(i);
Locale locale = new Locale(test[0], test[1], test[2]);
Locale locale = Locale.of(test[0], test[1], test[2]);
assertEquals(id + " lang", test.length > 3 ? test[3] : test[0], locale.getLanguage());
assertEquals(id + " region", test.length > 4 ? test[4] : test[1], locale.getCountry());
assertEquals(id + " variant", test.length > 5 ? test[5] : test[2], locale.getVariant());
@ -480,7 +480,7 @@ public class LocaleEnhanceTest extends IntlTest {
};
for (int i = 0; i < tests.length; ++i) {
String[] test = tests[i];
Locale locale = new Locale(test[0], test[1], test[2]);
Locale locale = Locale.of(test[0], test[1], test[2]);
assertEquals("case " + i, test[3], locale.toLanguageTag());
}
@ -638,11 +638,11 @@ public class LocaleEnhanceTest extends IntlTest {
public void testGetDisplayName() {
final Locale[] testLocales = {
Locale.ROOT,
new Locale("en"),
new Locale("en", "US"),
new Locale("", "US"),
new Locale("no", "NO", "NY"),
new Locale("", "", "NY"),
Locale.ENGLISH,
Locale.US,
Locale.of("", "US"),
Locale.of("no", "NO", "NY"),
Locale.of("", "", "NY"),
Locale.forLanguageTag("zh-Hans"),
Locale.forLanguageTag("zh-Hant"),
Locale.forLanguageTag("zh-Hans-CN"),
@ -709,15 +709,15 @@ public class LocaleEnhanceTest extends IntlTest {
// builder canonicalizes the three legacy locales:
// ja_JP_JP, th_TH_TH, no_NY_NO.
locale = builder.setLocale(new Locale("ja", "JP", "JP")).build();
locale = builder.setLocale(Locale.of("ja", "JP", "JP")).build();
assertEquals("ja_JP_JP languagetag", "ja-JP-u-ca-japanese", locale.toLanguageTag());
assertEquals("ja_JP_JP variant", "", locale.getVariant());
locale = builder.setLocale(new Locale("th", "TH", "TH")).build();
locale = builder.setLocale(Locale.of("th", "TH", "TH")).build();
assertEquals("th_TH_TH languagetag", "th-TH-u-nu-thai", locale.toLanguageTag());
assertEquals("th_TH_TH variant", "", locale.getVariant());
locale = builder.setLocale(new Locale("no", "NO", "NY")).build();
locale = builder.setLocale(Locale.of("no", "NO", "NY")).build();
assertEquals("no_NO_NY languagetag", "nn-NO", locale.toLanguageTag());
assertEquals("no_NO_NY language", "nn", locale.getLanguage());
assertEquals("no_NO_NY variant", "", locale.getVariant());
@ -725,7 +725,7 @@ public class LocaleEnhanceTest extends IntlTest {
// non-canonical, non-legacy locales are invalid
new BuilderILE("123_4567_89") {
public void call() {
b.setLocale(new Locale("123", "4567", "89"));
b.setLocale(Locale.of("123", "4567", "89"));
}
};
}
@ -1119,24 +1119,24 @@ public class LocaleEnhanceTest extends IntlTest {
public void testSerialize() {
final Locale[] testLocales = {
Locale.ROOT,
new Locale("en"),
new Locale("en", "US"),
new Locale("en", "US", "Win"),
new Locale("en", "US", "Win_XP"),
new Locale("ja", "JP"),
new Locale("ja", "JP", "JP"),
new Locale("th", "TH"),
new Locale("th", "TH", "TH"),
new Locale("no", "NO"),
new Locale("nb", "NO"),
new Locale("nn", "NO"),
new Locale("no", "NO", "NY"),
new Locale("nn", "NO", "NY"),
new Locale("he", "IL"),
new Locale("he", "IL", "var"),
new Locale("Language", "Country", "Variant"),
new Locale("", "US"),
new Locale("", "", "Java"),
Locale.ENGLISH,
Locale.US,
Locale.of("en", "US", "Win"),
Locale.of("en", "US", "Win_XP"),
Locale.JAPAN,
Locale.of("ja", "JP", "JP"),
Locale.of("th", "TH"),
Locale.of("th", "TH", "TH"),
Locale.of("no", "NO"),
Locale.of("nb", "NO"),
Locale.of("nn", "NO"),
Locale.of("no", "NO", "NY"),
Locale.of("nn", "NO", "NY"),
Locale.of("he", "IL"),
Locale.of("he", "IL", "var"),
Locale.of("Language", "Country", "Variant"),
Locale.of("", "US"),
Locale.of("", "", "Java"),
Locale.forLanguageTag("en-Latn-US"),
Locale.forLanguageTag("zh-Hans"),
Locale.forLanguageTag("zh-Hant-TW"),
@ -1209,7 +1209,7 @@ public class LocaleEnhanceTest extends IntlTest {
String lang = fields[0];
String country = (fields.length >= 2) ? fields[1] : "";
String variant = (fields.length == 3) ? fields[2] : "";
locale = new Locale(lang, country, variant);
locale = Locale.of(lang, country, variant);
}
// deserialize
@ -1287,17 +1287,17 @@ public class LocaleEnhanceTest extends IntlTest {
* 7033504: (lc) incompatible behavior change for ja_JP_JP and th_TH_TH locales
*/
public void testBug7033504() {
checkCalendar(new Locale("ja", "JP", "jp"), "java.util.GregorianCalendar");
checkCalendar(new Locale("ja", "jp", "jp"), "java.util.GregorianCalendar");
checkCalendar(new Locale("ja", "JP", "JP"), "java.util.JapaneseImperialCalendar");
checkCalendar(new Locale("ja", "jp", "JP"), "java.util.JapaneseImperialCalendar");
checkCalendar(Locale.of("ja", "JP", "jp"), "java.util.GregorianCalendar");
checkCalendar(Locale.of("ja", "jp", "jp"), "java.util.GregorianCalendar");
checkCalendar(Locale.of("ja", "JP", "JP"), "java.util.JapaneseImperialCalendar");
checkCalendar(Locale.of("ja", "jp", "JP"), "java.util.JapaneseImperialCalendar");
checkCalendar(Locale.forLanguageTag("en-u-ca-japanese"),
"java.util.JapaneseImperialCalendar");
checkDigit(new Locale("th", "TH", "th"), '0');
checkDigit(new Locale("th", "th", "th"), '0');
checkDigit(new Locale("th", "TH", "TH"), '\u0e50');
checkDigit(new Locale("th", "TH", "TH"), '\u0e50');
checkDigit(Locale.of("th", "TH", "th"), '0');
checkDigit(Locale.of("th", "th", "th"), '0');
checkDigit(Locale.of("th", "TH", "TH"), '\u0e50');
checkDigit(Locale.of("th", "TH", "TH"), '\u0e50');
checkDigit(Locale.forLanguageTag("en-u-nu-thai"), '\u0e50');
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -127,7 +127,7 @@ public class LocaleProviders {
}
static void adapterTest(String expected, String lang, String ctry) {
Locale testLocale = new Locale(lang, ctry);
Locale testLocale = Locale.of(lang, ctry);
LocaleProviderAdapter ldaExpected =
LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.valueOf(expected));
if (!ldaExpected.getDateFormatProvider().isSupportedLocale(testLocale)) {
@ -248,7 +248,7 @@ public class LocaleProviders {
static void bug8013086Test(String lang, String ctry) {
try {
// Throws a NullPointerException if the test fails.
System.out.println(new SimpleDateFormat("z", new Locale(lang, ctry)).parse("UTC"));
System.out.println(new SimpleDateFormat("z", Locale.of(lang, ctry)).parse("UTC"));
} catch (ParseException pe) {
// ParseException is fine in this test, as it's not "UTC"
}
@ -258,7 +258,7 @@ public class LocaleProviders {
if (IS_WINDOWS) {
Date sampleDate = new Date(0x10000000000L);
String expected = "\u5e73\u6210 16.11.03 (\u6c34) \u5348\u524d 11:53:47";
Locale l = new Locale("ja", "JP", "JP");
Locale l = Locale.of("ja", "JP", "JP");
SimpleDateFormat sdf = new SimpleDateFormat("GGGG yyyy.MMM.dd '('E')' a hh:mm:ss", l);
sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
String result = sdf.format(sampleDate);
@ -295,7 +295,7 @@ public class LocaleProviders {
static void bug8220227Test() {
if (IS_WINDOWS) {
Locale l = new Locale("xx","XX");
Locale l = Locale.of("xx","XX");
String country = l.getDisplayCountry();
if (country.endsWith("(XX)")) {
throw new RuntimeException(

Some files were not shown because too many files have changed in this diff Show More