Java Code Examples for java.util.Locale#GERMANY

The following examples show how to use java.util.Locale#GERMANY . 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: MinuteTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 2
Source File: MonthTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 3
Source File: MinuteTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 4
Source File: HourTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 5
Source File: MonthTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 6
Source File: MillisecondTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 7
Source File: MonthTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 8
Source File: MinuteTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 File: YearTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 10
Source File: LocaleContextHolderTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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 11
Source File: MinuteTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * 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 12
Source File: SecondTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 13
Source File: HourTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 14
Source File: WeekTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * 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 15
Source File: RbnfLenientScannerTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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 16
Source File: RbnfTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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 File: I18nApp.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
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 18
Source File: DateAdapterTest.java    From recheck with GNU Affero General Public License v3.0 5 votes vote down vote up
@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 19
Source File: CurrencyFormat.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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 File: GanttTest.java    From gantt with Apache License 2.0 4 votes vote down vote up
@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);
}