Java Code Examples for java.util.Locale#GERMANY
The following examples show how to use
java.util.Locale#GERMANY .
These examples are extracted from open source projects.
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 Project: SIMVA-SoS File: WeekTest.java License: Apache License 2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ @Test public void testGetFirstMillisecondWithCalendar() { Week w = new Week(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, w.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { w.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 2
Source Project: astor File: MinuteTests.java License: GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Minute m = new Minute(45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889559999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 3
Source Project: openstock File: HourTest.java License: GNU General Public License v3.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ @Test public void testGetFirstMillisecondWithCalendar() { Hour h = new Hour(2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955764000000L, h.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { h.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 4
Source Project: ECG-Viewer File: SecondTest.java License: GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ @Test public void testGetLastMillisecondWithCalendar() { Second s = new Second(50, 45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889550999L, s.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 5
Source Project: SIMVA-SoS File: MinuteTest.java License: Apache License 2.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ @Test public void testGetLastMillisecondWithCalendar() { Minute m = new Minute(45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889559999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 6
Source Project: spring4-understanding File: LocaleContextHolderTests.java License: Apache License 2.0 | 6 votes |
@Test public void testSetLocaleContext() { LocaleContext lc = new SimpleLocaleContext(Locale.GERMAN); LocaleContextHolder.setLocaleContext(lc); assertSame(lc, LocaleContextHolder.getLocaleContext()); assertEquals(Locale.GERMAN, LocaleContextHolder.getLocale()); assertEquals(TimeZone.getDefault(), LocaleContextHolder.getTimeZone()); lc = new SimpleLocaleContext(Locale.GERMANY); LocaleContextHolder.setLocaleContext(lc); assertSame(lc, LocaleContextHolder.getLocaleContext()); assertEquals(Locale.GERMANY, LocaleContextHolder.getLocale()); assertEquals(TimeZone.getDefault(), LocaleContextHolder.getTimeZone()); LocaleContextHolder.resetLocaleContext(); assertNull(LocaleContextHolder.getLocaleContext()); assertEquals(Locale.getDefault(), LocaleContextHolder.getLocale()); assertEquals(TimeZone.getDefault(), LocaleContextHolder.getTimeZone()); }
Example 7
Source Project: astor File: YearTests.java License: GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Year y = new Year(2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1009843199999L, y.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { y.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 8
Source Project: openstock File: MinuteTest.java License: GNU General Public License v3.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ @Test public void testGetLastMillisecondWithCalendar() { Minute m = new Minute(45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889559999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 9
Source Project: ECG-Viewer File: MonthTest.java License: GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ @Test public void testGetLastMillisecondWithCalendar() { Month m = new Month(3, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(986083199999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 10
Source Project: openstock File: MillisecondTest.java License: GNU General Public License v3.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ @Test public void testGetLastMillisecondWithCalendar() { Millisecond m = new Millisecond(250, 50, 45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889550250L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 11
Source Project: ECG-Viewer File: MonthTest.java License: GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ @Test public void testGetFirstMillisecondWithCalendar() { Month m = new Month(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 12
Source Project: astor File: HourTests.java License: GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Hour h = new Hour(2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955764000000L, h.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { h.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 13
Source Project: astor File: MinuteTests.java License: GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Minute m = new Minute(45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889559999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 14
Source Project: buffer_bci File: MonthTest.java License: GNU General Public License v3.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ @Test public void testGetFirstMillisecondWithCalendar() { Month m = new Month(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 15
Source Project: recheck File: DateAdapterTest.java License: GNU Affero General Public License v3.0 | 5 votes |
@Test public void can_parse_default_dateFormat_from_before_refactoring() { final Date origin = new Date(); final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z", Locale.GERMANY ); dateFormat.setTimeZone( TimeZone.getTimeZone( "GMT+2" ) ); final String defaultdateFormatBeforeRefactoring = dateFormat.format( origin ); assertThat( dateAdapter.unmarshal( defaultdateFormatBeforeRefactoring ) ).isInSameSecondAs( origin ); }
Example 16
Source Project: j2objc File: RbnfTest.java License: Apache License 2.0 | 5 votes |
/** * Perform a simple spot check on the German spellout rules */ @Test public void TestGermanSpellout() { RuleBasedNumberFormat formatter = new RuleBasedNumberFormat(Locale.GERMANY, RuleBasedNumberFormat.SPELLOUT); String[][] testData = { { "1", "eins" }, { "15", "f\u00fcnfzehn" }, { "20", "zwanzig" }, { "23", "drei\u00ADund\u00ADzwanzig" }, { "73", "drei\u00ADund\u00ADsiebzig" }, { "88", "acht\u00ADund\u00ADachtzig" }, { "100", "ein\u00ADhundert" }, { "106", "ein\u00ADhundert\u00ADsechs" }, { "127", "ein\u00ADhundert\u00ADsieben\u00ADund\u00ADzwanzig" }, { "200", "zwei\u00ADhundert" }, { "579", "f\u00fcnf\u00ADhundert\u00ADneun\u00ADund\u00ADsiebzig" }, { "1,000", "ein\u00ADtausend" }, { "2,000", "zwei\u00ADtausend" }, { "3,004", "drei\u00ADtausend\u00ADvier" }, { "4,567", "vier\u00ADtausend\u00ADf\u00fcnf\u00ADhundert\u00ADsieben\u00ADund\u00ADsechzig" }, { "15,943", "f\u00fcnfzehn\u00ADtausend\u00ADneun\u00ADhundert\u00ADdrei\u00ADund\u00ADvierzig" }, { "2,345,678", "zwei Millionen drei\u00ADhundert\u00ADf\u00fcnf\u00ADund\u00ADvierzig\u00ADtausend\u00AD" + "sechs\u00ADhundert\u00ADacht\u00ADund\u00ADsiebzig" } }; doTest(formatter, testData, true); }
Example 17
Source Project: j2objc File: RbnfLenientScannerTest.java License: Apache License 2.0 | 5 votes |
/** * Perform a simple spot check on the German spellout rules */ @Test public void TestGermanSpellout() { RuleBasedNumberFormat formatter = new RuleBasedNumberFormat(Locale.GERMANY, RuleBasedNumberFormat.SPELLOUT); formatter.setLenientScannerProvider(provider); formatter.setLenientParseMode(true); String[][] lpTestData = { { "ein Tausend sechs Hundert fuenfunddreissig", "1,635" } }; doLenientParseTest(formatter, lpTestData); }
Example 18
Source Project: jasperreports File: I18nApp.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ private static Locale chooseLocale() { LocaleWrapper[] locales = new LocaleWrapper[] { new LocaleWrapper(new Locale("cs", "CZ")), new LocaleWrapper(Locale.GERMANY), new LocaleWrapper(Locale.US), new LocaleWrapper(Locale.FRANCE), new LocaleWrapper(new Locale("pt", "PT")), new LocaleWrapper(new Locale("ro", "RO")), new LocaleWrapper(new Locale("sk", "SK")) }; LocaleWrapper locale = (LocaleWrapper)JOptionPane.showInputDialog( null, "Choose the locale", "Locale", JOptionPane.PLAIN_MESSAGE, null, locales, null ); if (locale != null) return locale.getLocale(); return null; }
Example 19
Source Project: openjdk-jdk8u File: CurrencyFormat.java License: GNU General Public License v2.0 | 4 votes |
static void testFormatting() { boolean failed = false; Locale[] locales = { Locale.US, Locale.JAPAN, Locale.GERMANY, Locale.ITALY, new Locale("it", "IT", "EURO") }; Currency[] currencies = { null, Currency.getInstance("USD"), Currency.getInstance("JPY"), Currency.getInstance("DEM"), Currency.getInstance("EUR"), }; String[][] expecteds = { {"$1,234.56", "$1,234.56", "JPY1,235", "DEM1,234.56", "EUR1,234.56"}, {"\uFFE51,235", "USD1,234.56", "\uFFE51,235", "DEM1,234.56", "EUR1,234.56"}, {"1.234,56 \u20AC", "1.234,56 USD", "1.235 JPY", "1.234,56 DM", "1.234,56 \u20AC"}, {"\u20AC 1.234,56", "USD 1.234,56", "JPY 1.235", "DEM 1.234,56", "\u20AC 1.234,56"}, {"\u20AC 1.234,56", "USD 1.234,56", "JPY 1.235", "DEM 1.234,56", "\u20AC 1.234,56"}, }; for (int i = 0; i < locales.length; i++) { Locale locale = locales[i]; NumberFormat format = NumberFormat.getCurrencyInstance(locale); for (int j = 0; j < currencies.length; j++) { Currency currency = currencies[j]; String expected = expecteds[i][j]; if (currency != null) { format.setCurrency(currency); int digits = currency.getDefaultFractionDigits(); format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } String result = format.format(1234.56); if (!result.equals(expected)) { failed = true; System.out.println("FAIL: Locale " + locale + (currency == null ? ", default currency" : (", currency: " + currency)) + ", expected: " + expected + ", actual: " + result); } } } if (failed) { throw new RuntimeException(); } }
Example 20
Source Project: gantt File: GanttTest.java License: Apache License 2.0 | 4 votes |
@Test public void clientWeekNumberCalculation_lastWeekIf2014_weekNumber1() { TimeZone timezone = TimeZone.getTimeZone("Asia/Tehran"); Locale locale = Locale.GERMANY; DateTime week1_2014 = new DateTime(2014, 1, 1, 0, 0, 0, 000, DateTimeZone.forTimeZone(timezone)); DateTime week2_2014 = new DateTime(2014, 1, 6, 0, 0, 0, 000, DateTimeZone.forTimeZone(timezone)); DateTime week52_2014 = new DateTime(2014, 12, 28, 0, 0, 0, 000, DateTimeZone.forTimeZone(timezone)); DateTime lastDayOf2014 = new DateTime(2014, 12, 31, 0, 0, 0, 000, DateTimeZone.forTimeZone(timezone)); DateTime week1_2015 = new DateTime(2015, 1, 4, 0, 0, 0, 000, DateTimeZone.forTimeZone(timezone)); DateTime week2_2015 = new DateTime(2015, 1, 5, 0, 0, 0, 000, DateTimeZone.forTimeZone(timezone)); Calendar cal = Calendar.getInstance(timezone, locale); long tzOfset = getTimezoneOffset(timezone, locale); int weekNumber = GanttUtil.getWeekNumber(new Date(week1_2014.toDate() .getTime() + tzOfset), getTimezoneOffset(timezone, locale), cal.getFirstDayOfWeek()); Assert.assertEquals(1, weekNumber); weekNumber = GanttUtil.getWeekNumber(new Date(week2_2014.toDate() .getTime() + tzOfset), getTimezoneOffset(timezone, locale), cal.getFirstDayOfWeek()); Assert.assertEquals(2, weekNumber); weekNumber = GanttUtil.getWeekNumber(lastDayOf2014.toDate(), getTimezoneOffset(timezone, locale), cal.getFirstDayOfWeek()); Assert.assertEquals(1, weekNumber); weekNumber = GanttUtil.getWeekNumber(new Date(week52_2014.toDate() .getTime() + tzOfset), getTimezoneOffset(timezone, locale), cal.getFirstDayOfWeek()); Assert.assertEquals(52, weekNumber); weekNumber = GanttUtil.getWeekNumber(new Date(week1_2015.toDate() .getTime() + tzOfset), getTimezoneOffset(timezone, locale), cal.getFirstDayOfWeek()); Assert.assertEquals(1, weekNumber); weekNumber = GanttUtil.getWeekNumber(new Date(week2_2015.toDate() .getTime() + tzOfset), getTimezoneOffset(timezone, locale), cal.getFirstDayOfWeek()); Assert.assertEquals(2, weekNumber); }