List of usage examples for java.util Locale CANADA
Locale CANADA
To view the source code for java.util Locale CANADA.
Click Source Link
From source file:com.isalnikov.config.MessageTest.java
@Test public void testHelloParamsConfigurer() { System.out.println(messageHelper.getMessage("hello.name", "igor")); System.out.println(messageHelper.getMessage(Locale.CANADA, "hello.name", "igor")); System.out.println(messageHelper.getMessage(Locale.ENGLISH, "hello.name", "igor")); System.out.println(messageHelper.getMessage(Locale.ENGLISH, "hello.name", "")); System.out.println(messageHelper.getMessage(new Locale("ru"), "hello.name", "")); System.out.println(messageHelper.getMessage(new Locale("ru_RU"), "hello.name", "")); }
From source file:org.openmrs.web.controller.concept.ConceptStopWordFormControllerTest.java
/** * @see {@link ConceptStopWordFormController#handleSubmission(HttpSession, ConceptStopWordFormBackingObject, org.springframework.validation.BindingResult) *//*w ww. ja va 2s . c o m*/ @Test @Verifies(value = "should return error message for an empty ConceptStopWord", method = "handleSubmission(HttpSession, ConceptStopWordFormBackingObject, BindingResult)") public void handleSubmission_shouldReturnErrorMessageForAnEmptyConceptStopWord() throws Exception { ConceptStopWordFormController controller = (ConceptStopWordFormController) applicationContext .getBean("conceptStopWordFormController"); HttpSession mockSession = new MockHttpSession(); ConceptStopWord conceptStopWord = new ConceptStopWord("", Locale.CANADA); mockSession.setAttribute("value", conceptStopWord.getValue()); BindException errors = new BindException(conceptStopWord, "value"); controller.handleSubmission(mockSession, conceptStopWord, errors); ObjectError objectError = (ObjectError) errors.getAllErrors().get(0); Assert.assertTrue(errors.hasErrors()); Assert.assertEquals(1, errors.getErrorCount()); Assert.assertEquals("ConceptStopWord.error.value.empty", objectError.getCode()); }
From source file:org.opendatakit.common.android.utilities.ODKDataUtilsTest.java
@Test public void testNormalizeDisplayName() throws JsonProcessingException { Map<String, Object> langMap = new TreeMap<String, Object>(); langMap.put("en_US", "This is a test"); langMap.put("en_GB", "Test is This"); langMap.put("en", "Huh Test"); langMap.put("fr", "Je suis"); langMap.put("default", "No way!"); String value = ODKFileUtils.mapper.writeValueAsString(langMap); String match;/* ww w.ja va 2 s .c om*/ Locale.setDefault(Locale.US); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("This is a test", match); Locale.setDefault(Locale.UK); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Test is This", match); Locale.setDefault(Locale.CANADA); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Huh Test", match); Locale.setDefault(Locale.CANADA_FRENCH); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Je suis", match); Locale.setDefault(Locale.GERMANY); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("No way!", match); Locale.setDefault(Locale.US); }
From source file:com.gettextresourcebundle.GettextResourceBundleControlTest.java
/** * test that PO files loaded from the file system will reload after * cache timeout occurs and modified dates are different * @throws IOException//from w ww. j a v a 2s . com */ @Test public void testFileReloads() throws IOException { File localeDirectory = new File("./src/test/resources/locale"); File localeNewDirectory = new File("./src/test/resources/localeNew"); File targetDirectory = new File("./target/testLocales"); targetDirectory.mkdirs(); //unit test with 5 second cache time final long cacheTTL = 5 * 1000l; GettextResourceBundleControl.setCacheTTL(cacheTTL); FileUtils.copyDirectory(localeDirectory, targetDirectory, false); ResourceBundle en_US = ResourceBundle.getBundle(targetDirectory.getAbsolutePath(), Locale.US, GettextResourceBundleControl.getControl("test")); assertEquals("The locale key should be en_US for the en_US locale", "en_US", en_US.getString("locale")); ResourceBundle en_CA = ResourceBundle.getBundle(targetDirectory.getAbsolutePath(), Locale.CANADA, GettextResourceBundleControl.getControl("test")); assertEquals("The locale key should be en_CA for the en_CA locale", "en_CA", en_CA.getString("locale")); FileUtils.copyDirectory(localeNewDirectory, targetDirectory, false); en_US = ResourceBundle.getBundle(targetDirectory.getAbsolutePath(), Locale.US, GettextResourceBundleControl.getControl("test")); assertEquals("The locale key should be en_US for the en_US locale before cache expiry", "en_US", en_US.getString("locale")); en_CA = ResourceBundle.getBundle(targetDirectory.getAbsolutePath(), Locale.CANADA, GettextResourceBundleControl.getControl("test")); assertEquals("The locale key should be en_CA for the en_CA locale before cache expiry", "en_CA", en_CA.getString("locale")); //wait until cacheTTL passes so that cache expires long end = System.currentTimeMillis() + (cacheTTL); while (end > System.currentTimeMillis()) { try { Thread.sleep(end - System.currentTimeMillis()); } catch (InterruptedException e) { } } en_US = ResourceBundle.getBundle(targetDirectory.getAbsolutePath(), Locale.US, GettextResourceBundleControl.getControl("test")); assertEquals("The locale key should be en_US #2 for the en_US locale before cache expiry", "en_US #2", en_US.getString("locale")); en_CA = ResourceBundle.getBundle(targetDirectory.getAbsolutePath(), Locale.CANADA, GettextResourceBundleControl.getControl("test")); assertEquals("The locale key should be en_CA #2 for the en_CA locale before cache expiry", "en_CA #2", en_CA.getString("locale")); }
From source file:com.example.michael.paradis2_habittracker.DatePickerFragment.java
public void onDateSet(DatePicker view, int year, int month, int day) { // Do something with the date chosen by the user Calendar c = Calendar.getInstance(); c.set(year, month, day);/*ww w . j ava2 s . com*/ Date date = c.getTime(); EditText input = (EditText) getActivity().findViewById(R.id.NewHabitDate); SimpleDateFormat formats = new SimpleDateFormat("yyyy-MM-dd", Locale.CANADA); input.setText(formats.format(date)); int[] weekDayButtons = ((CreateNewHabit) getActivity()).getWeekDayButtonsid(); for (int i = 0; i < 7; i++) { ((ToggleButton) getActivity().findViewById(weekDayButtons[i])).setChecked(false); } int weekday = new DayOfWeek(c).getDayOfWeek(); ((ToggleButton) getActivity().findViewById(weekDayButtons[weekday])).toggle(); //this.dismiss(); }
From source file:org.obiba.mica.dataset.service.HarmonizedDatasetServiceTest.java
private HarmonizationDataset buildHarmonizationDataset(String id, StudyTable... studyTables) { HarmonizationDataset ds = new HarmonizationDataset(); for (StudyTable s : studyTables) { ds.addStudyTable(s);/*from w w w. ja va 2s . c o m*/ } ds.setId(id); ds.setName(new LocalizedString(Locale.CANADA, "dataset" + id)); return ds; }
From source file:org.opendatakit.utilities.LocalizationUtilsTest.java
@Test public void testNormalizeDisplayName() throws JsonProcessingException { Map<String, Object> langMap = new TreeMap<String, Object>(); langMap.put("en_US", "This is a test"); langMap.put("en_GB", "Test is This"); langMap.put("en", "Huh Test"); langMap.put("fr", "Je suis"); langMap.put("default", "No way!"); Map<String, Object> topMap = new TreeMap<String, Object>(); topMap.put("text", langMap); String value = ODKFileUtils.mapper.writeValueAsString(topMap); Locale defaultLocale;//from w ww . ja v a2 s . c om String full_locale; String match; Locale.setDefault(Locale.US); defaultLocale = Locale.getDefault(); full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry(); match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value); assertEquals("This is a test", match); Locale.setDefault(Locale.UK); defaultLocale = Locale.getDefault(); full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry(); match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value); assertEquals("Test is This", match); Locale.setDefault(Locale.CANADA); defaultLocale = Locale.getDefault(); full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry(); match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value); assertEquals("Huh Test", match); Locale.setDefault(Locale.CANADA_FRENCH); defaultLocale = Locale.getDefault(); full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry(); match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value); assertEquals("Je suis", match); Locale.setDefault(Locale.GERMANY); defaultLocale = Locale.getDefault(); full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry(); match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value); assertEquals("No way!", match); Locale.setDefault(Locale.US); }
From source file:org.codekaizen.vtj.text.BpNumberFormatTest.java
/** * DOCUMENT ME!/*from w w w . j av a 2 s . c om*/ */ @Test public void testFormatting() { NumberFormat fmt1 = null; NumberFormat fmt2 = null; String s1 = null; String s2 = null; Number num1 = null; fmt1 = new BpNumberFormat(BpNumberFormat.JVM_NUMBER, null); fmt2 = NumberFormat.getNumberInstance(); num1 = new Integer(25436); s1 = fmt1.format(num1); s2 = fmt2.format(num1); assertEquals(s2, s1); num1 = new Double(1228.744); s1 = fmt1.format(num1); s2 = fmt2.format(num1); assertEquals(s2, s1); fmt1 = new BpNumberFormat(BpNumberFormat.JVM_CURRENCY, null); fmt2 = NumberFormat.getCurrencyInstance(); num1 = new Integer(25436); s1 = fmt1.format(num1); s2 = fmt2.format(num1); assertEquals(s2, s1); num1 = new Double(1228.744); s1 = fmt1.format(num1); s2 = fmt2.format(num1); assertEquals(s2, s1); fmt1 = new BpNumberFormat(BpNumberFormat.JVM_CURRENCY, Locale.CANADA); fmt2 = NumberFormat.getCurrencyInstance(Locale.CANADA); num1 = new Integer(25436); s1 = fmt1.format(num1); s2 = fmt2.format(num1); assertEquals(s2, s1); num1 = new Double(1228.744); s1 = fmt1.format(num1); s2 = fmt2.format(num1); assertEquals(s2, s1); fmt1 = new BpNumberFormat(BpNumberFormat.JVM_PERCENT, null); fmt2 = NumberFormat.getPercentInstance(); num1 = new Double(0.7444); s1 = fmt1.format(num1); s2 = fmt2.format(num1); assertEquals(s2, s1); }
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditExpenseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.edit_expense); sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.CANADA); expenseName = this.getIntent().getExtras().getString("expenseName"); claimName = this.getIntent().getExtras().getString("claimName"); date = (EditText) findViewById(R.id.Edit_Expense_Date2); expenseNameInput = (EditText) findViewById(R.id.Edit_Expense_Name2); expenseCostInput = (EditText) findViewById(R.id.Edit_Expense_Cost2); expenseDescriptionInput = (EditText) findViewById(R.id.Edit_Expense_Description2); currencySpinner = (Spinner) findViewById(R.id.CurrencySpinner2); categorySpinner = (Spinner) findViewById(R.id.CategorySpinner2); expenseReceiptView = (ImageView) findViewById(R.id.Edit_Expense_Image2); claimList = ClaimListController.getClaimList(); claim = claimList.getClaim(claimName); expenseList = claim.getExpenseList(); expense = expenseList.getExpense(expenseName); // show initial image if (expense.getPicture() != null) { imgShow = expense.getPicture();/* w ww .ja va 2s . c om*/ Bitmap bm = BitmapFactory.decodeByteArray(imgShow, 0, imgShow.length); sizeNum = imgShow.length; size = sizeNum.toString(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); expenseReceiptView.setMinimumHeight(dm.heightPixels); expenseReceiptView.setMinimumWidth(dm.widthPixels); expenseReceiptView.setImageBitmap(bm); } expenseReceiptView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { // Create the Intent for Image Gallery. Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); // Start new activity with the LOAD_IMAGE_RESULTS to handle back the results when image is picked from the Image Gallery. startActivityForResult(i, 1); return true; } }); expenseReceiptView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { loadPhoto((ImageView) v, 100, 100); } }); currencySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { expense.setCurr(parent.getItemAtPosition(position).toString()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { expense.setCat(parent.getItemAtPosition(position).toString()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); set_on_click(); }
From source file:org.opendatakit.common.android.utilities.ODKDataUtilsTest.java
@Test public void testNormalizeDisplayName2() { Map<String, Object> langMap = new TreeMap<String, Object>(); langMap.put("en_US", "This is a test"); langMap.put("en_GB", "Test is This"); langMap.put("en", "Huh Test"); langMap.put("fr", "Je suis"); langMap.put("default", "No way!"); String match;/*from w ww. j ava2s. c o m*/ Locale.setDefault(Locale.US); match = ODKDataUtils.getLocalizedDisplayName(langMap); assertEquals("This is a test", match); Locale.setDefault(Locale.UK); match = ODKDataUtils.getLocalizedDisplayName(langMap); assertEquals("Test is This", match); Locale.setDefault(Locale.CANADA); match = ODKDataUtils.getLocalizedDisplayName(langMap); assertEquals("Huh Test", match); Locale.setDefault(Locale.CANADA_FRENCH); match = ODKDataUtils.getLocalizedDisplayName(langMap); assertEquals("Je suis", match); Locale.setDefault(Locale.GERMANY); match = ODKDataUtils.getLocalizedDisplayName(langMap); assertEquals("No way!", match); Locale.setDefault(Locale.US); }