Java Code Examples for java.time.chrono.Chronology#ofLocale()

The following examples show how to use java.time.chrono.Chronology#ofLocale() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestExampleCode.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider= "HijrahTypeNames")
public void test_HijrahTypeViaLocale(String calendarId, String calendarType) {
    Locale.Builder builder = new Locale.Builder();
    builder.setLanguage("en").setRegion("US");
    builder.setUnicodeLocaleKeyword("ca", calendarType);
    Locale locale = builder.build();
    Chronology chrono = Chronology.ofLocale(locale);
    System.out.printf(" Locale language tag: %s, Chronology ID: %s, type: %s%n",
            locale.toLanguageTag(), chrono, chrono.getCalendarType());
    Chronology expected = Chronology.of(calendarId);
    assertEquals(chrono, expected, "Expected chronology not found");
}
 
Example 2
Source File: TCKChronology.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test(expected=DateTimeException.class)
public void test_lookupLocale() {
    Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA");
    builder.setUnicodeLocaleKeyword("ca", "xxx");

    Locale locale = builder.build();
    Chronology.ofLocale(locale);
}
 
Example 3
Source File: TestExampleCode.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider= "HijrahTypeNames")
public void test_HijrahTypeViaLocale(String calendarId, String calendarType) {
    Locale.Builder builder = new Locale.Builder();
    builder.setLanguage("en").setRegion("US");
    builder.setUnicodeLocaleKeyword("ca", calendarType);
    Locale locale = builder.build();
    Chronology chrono = Chronology.ofLocale(locale);
    System.out.printf(" Locale language tag: %s, Chronology ID: %s, type: %s%n",
            locale.toLanguageTag(), chrono, chrono.getCalendarType());
    Chronology expected = Chronology.of(calendarId);
    assertEquals(chrono, expected, "Expected chronology not found");
}
 
Example 4
Source File: TCKThaiBuddhistChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_fullTag_thaiCalendarFromElsewhere() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-buddhist"));
    Assert.assertEquals(test.getId(), "ThaiBuddhist");
    Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE);
}
 
Example 5
Source File: TCKThaiBuddhistChronology.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldTH_noVariant() {  // deliberately different to Calendar
    Chronology test = Chronology.ofLocale(new Locale("th", "TH"));
    Assert.assertEquals(test.getId(), "ISO");
    Assert.assertEquals(test, IsoChronology.INSTANCE);
}
 
Example 6
Source File: TCKJapaneseChronology.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_fullTag_japaneseCalendarFromJapan() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("ja-JP-u-ca-japanese"));
    Assert.assertEquals(test.getId(), "Japanese");
    Assert.assertEquals(test, JapaneseChronology.INSTANCE);
}
 
Example 7
Source File: TCKThaiBuddhistChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_fullTag_thaiCalendarFromElsewhere() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-buddhist"));
    Assert.assertEquals(test.getId(), "ThaiBuddhist");
    Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE);
}
 
Example 8
Source File: TCKThaiBuddhistChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldTH_noVariant() {  // deliberately different to Calendar
    Chronology test = Chronology.ofLocale(new Locale("th", "TH"));
    Assert.assertEquals(test.getId(), "ISO");
    Assert.assertEquals(test, IsoChronology.INSTANCE);
}
 
Example 9
Source File: TCKThaiBuddhistChronology.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_fullTag_thaiCalendarFromElsewhere() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-buddhist"));
    Assert.assertEquals(test.getId(), "ThaiBuddhist");
    Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE);
}
 
Example 10
Source File: TCKThaiBuddhistChronology.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_fullTag_thaiCalendarFromElsewhere() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-buddhist"));
    Assert.assertEquals(test.getId(), "ThaiBuddhist");
    Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE);
}
 
Example 11
Source File: TCKThaiBuddhistChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldTH_noVariant() {  // deliberately different to Calendar
    Chronology test = Chronology.ofLocale(new Locale("th", "TH"));
    Assert.assertEquals(test.getId(), "ISO");
    Assert.assertEquals(test, IsoChronology.INSTANCE);
}
 
Example 12
Source File: TCKThaiBuddhistChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldTH_variant() {
    Chronology test = Chronology.ofLocale(new Locale("th", "TH", "TH"));
    Assert.assertEquals(test.getId(), "ISO");
    Assert.assertEquals(test, IsoChronology.INSTANCE);
}
 
Example 13
Source File: TCKThaiBuddhistChronology.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldTH_variant() {
    Chronology test = Chronology.ofLocale(new Locale("th", "TH", "TH"));
    Assert.assertEquals(test.getId(), "ISO");
    Assert.assertEquals(test, IsoChronology.INSTANCE);
}
 
Example 14
Source File: TCKThaiBuddhistChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldTH_variant() {
    Chronology test = Chronology.ofLocale(new Locale("th", "TH", "TH"));
    Assert.assertEquals(test.getId(), "ISO");
    Assert.assertEquals(test, IsoChronology.INSTANCE);
}
 
Example 15
Source File: TCKThaiBuddhistChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldTH_noVariant() {  // deliberately different to Calendar
    Chronology test = Chronology.ofLocale(new Locale("th", "TH"));
    Assert.assertEquals(test.getId(), "ISO");
    Assert.assertEquals(test, IsoChronology.INSTANCE);
}
 
Example 16
Source File: TCKThaiBuddhistChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_fullTag_thaiCalendarFromElsewhere() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-buddhist"));
    Assert.assertEquals(test.getId(), "ThaiBuddhist");
    Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE);
}
 
Example 17
Source File: TCKJapaneseChronology.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldJP_variant() {
    Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP"));
    Assert.assertEquals(test.getId(), "Japanese");
    Assert.assertEquals(test, JapaneseChronology.INSTANCE);
}
 
Example 18
Source File: TCKJapaneseChronology.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_oldJP_variant() {
    Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP"));
    Assert.assertEquals(test.getId(), "Japanese");
    Assert.assertEquals(test, JapaneseChronology.INSTANCE);
}
 
Example 19
Source File: TCKThaiBuddhistChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_fullTag_thaiCalendarFromThai() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("th-TH-u-ca-buddhist"));
    Assert.assertEquals(test.getId(), "ThaiBuddhist");
    Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE);
}
 
Example 20
Source File: TCKJapaneseChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_chrono_byLocale_fullTag_japaneseCalendarFromJapan() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("ja-JP-u-ca-japanese"));
    Assert.assertEquals(test.getId(), "Japanese");
    Assert.assertEquals(test, JapaneseChronology.INSTANCE);
}