List of usage examples for java.util Locale GERMANY
Locale GERMANY
To view the source code for java.util Locale GERMANY.
Click Source Link
From source file:ConstantLocaleUsage.java
public static void main(String[] argv) { NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setParseIntegerOnly(false); double usersNumber; if (argv.length == 1) try {/*from ww w .j av a 2s .co m*/ usersNumber = numberFormat.parse(argv[0]).doubleValue(); } catch (ParseException e) { usersNumber = 197912.29; } else usersNumber = 1976.0826; numberFormat = NumberFormat.getNumberInstance(Locale.US); System.out.println("User's number (US): " + numberFormat.format(usersNumber)); numberFormat = NumberFormat.getNumberInstance(Locale.GERMANY); System.out.println("User's number (GERMANY): " + numberFormat.format(usersNumber)); numberFormat = NumberFormat.getNumberInstance(); System.out.println("User's number (DEFAULT LOCALE): " + numberFormat.format(usersNumber)); }
From source file:MainClass.java
public static void main(String[] args) { Date today = new Date(); Locale[] locales = { Locale.US, Locale.UK, Locale.GERMANY, Locale.FRANCE }; int[] styles = { DateFormat.FULL, DateFormat.LONG, DateFormat.MEDIUM, DateFormat.SHORT }; DateFormat fmt;//from ww w . ja v a 2 s .c o m String[] styleText = { "FULL", "LONG", "MEDIUM", "SHORT" }; // Output the date for each local in four styles for (int i = 0; i < locales.length; i++) { System.out.println("\nThe Date for " + locales[i].getDisplayCountry() + ":"); for (int j = 0; j < styles.length; j++) { fmt = DateFormat.getDateInstance(styles[j], locales[i]); System.out.println("\tIn " + styleText[j] + " is " + fmt.format(today)); } } }
From source file:Main.java
public static Date weekDayOfWeek(Date startWeekDate, int day) { Calendar calendar = Calendar.getInstance(Locale.GERMANY); calendar.setTime(startWeekDate);//from ww w . j av a 2 s .c o m calendar.add(Calendar.DAY_OF_YEAR, day); return calendar.getTime(); }
From source file:org.polymap.rhei.field.BetweenFormField.java
public static Date dayStart(Date date) { Calendar cal = Calendar.getInstance(Locale.GERMANY); cal.setTime(date);/*www. jav a 2s . c om*/ cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:org.polymap.rhei.field.BetweenFormField.java
public static Date dayEnd(Date date) { Calendar cal = Calendar.getInstance(Locale.GERMANY); cal.setTime(date);/* w ww.jav a 2s. c om*/ cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); cal.add(Calendar.DAY_OF_MONTH, 1); return cal.getTime(); }
From source file:de.perdian.commons.i18n.polyglot.PolyglotImplTest.java
@Test public void testGetMeta() { StaticMessageSource messageSource = new StaticMessageSource(); messageSource.addMessage("key1", Locale.GERMANY, "value1"); messageSource.addMessage("key2", Locale.GERMANY, "value2"); PolyglotImpl<ExamplePolyglotSimple> polyglotImpl = new PolyglotImpl<>(); polyglotImpl.setInstanceClass(ExamplePolyglotSimple.class); polyglotImpl.setMessageSource(messageSource); PolyglotMeta polyglotMeta = polyglotImpl.getMeta(Locale.GERMANY); Assert.assertEquals(Locale.GERMANY, polyglotMeta.getLocale()); Assert.assertEquals(2, polyglotMeta.getKeys().size()); Assert.assertEquals(0, polyglotMeta.getMissingValueKeys().size()); Assert.assertTrue(polyglotMeta.getKeys().containsAll(Arrays.asList("key1", "key2"))); }
From source file:de.avpptr.umweltzone.utils.ContentProvider.java
@NonNull public static List<Faq> getFaqs(final Context context) { // Do not accidentally compare with Locale.GERMAN if (Locale.getDefault().equals(Locale.GERMANY)) { return getContent(context, "faqs_de", Faq.class); }/*from w w w . j a va 2 s . co m*/ return getContent(context, "faqs_en", Faq.class); }
From source file:org.openhie.openempi.util.DateConverterTest.java
public void testInternationalization() throws Exception { List<Locale> locales = new ArrayList<Locale>() { private static final long serialVersionUID = 1L; {//from ww w . j ava 2s . co m add(Locale.US); add(Locale.GERMANY); add(Locale.FRANCE); add(Locale.CHINA); add(Locale.ITALY); } }; for (Locale locale : locales) { LocaleContextHolder.setLocale(locale); testConvertStringToDate(); testConvertDateToString(); testConvertStringToTimestamp(); testConvertTimestampToString(); } }
From source file:de.perdian.commons.i18n.polyglot.PolyglotInvocationHandlerTest.java
@Test public void testInvoke() { MessageSource messageSource = Mockito.mock(MessageSource.class); PolyglotInvocationInfo invocationInfo = new PolyglotInvocationInfo(); invocationInfo.setKey(UUID.randomUUID().toString()); invocationInfo.setDefaultValue(UUID.randomUUID().toString()); Object[] arguments = new Object[] { "a", 42 }; PolyglotInvocationHandler invocationHandler = new PolyglotInvocationHandler(); invocationHandler.setLocale(Locale.GERMANY); invocationHandler.setMessageSource(messageSource); invocationHandler.setInfoMap(Collections.singletonMap((Method) null, invocationInfo)); invocationHandler.invoke(null, null, arguments); // Make sure all the information get's passed correctly to the // underlaying MessageSource implementation Mockito.verify(messageSource).getMessage(Matchers.eq(invocationInfo.getKey()), Matchers.eq(arguments), Matchers.eq(invocationInfo.getDefaultValue()), Matchers.eq(invocationHandler.getLocale())); }
From source file:org.openmrs.contrib.metadatarepository.util.DateConverterTest.java
public void testInternationalization() throws Exception { final List<Locale> locales = new ArrayList<Locale>() { private static final long serialVersionUID = 1L; {/* w ww .j av a 2s .c o m*/ add(Locale.US); add(Locale.GERMANY); add(Locale.FRANCE); add(Locale.CHINA); add(Locale.ITALY); } }; for (final Locale locale : locales) { LocaleContextHolder.setLocale(locale); testConvertStringToDate(); testConvertDateToString(); testConvertStringToTimestamp(); testConvertTimestampToString(); } }