List of usage examples for java.util Locale CHINA
Locale CHINA
To view the source code for java.util Locale CHINA.
Click Source Link
From source file:hk.idv.kenson.jrconsole.Console.java
/** * /*from www .j ava2 s .c o m*/ * @param localeString * @return */ private static Locale getLocale(String localeString) { if ("default".equals(localeString)) return Locale.getDefault(); if ("canada".equals(localeString)) return Locale.CANADA; if ("canada_french".equals(localeString)) return Locale.CANADA_FRENCH; if ("china".equals(localeString)) return Locale.CHINA; if ("chinese".equals(localeString)) return Locale.CHINESE; if ("english".equals(localeString)) return Locale.ENGLISH; if ("franch".equals(localeString)) return Locale.FRANCE; if ("german".equals(localeString)) return Locale.GERMAN; if ("germany".equals(localeString)) return Locale.GERMANY; if ("italian".equals(localeString)) return Locale.ITALIAN; if ("italy".equals(localeString)) return Locale.ITALY; if ("japan".equals(localeString)) return Locale.JAPAN; if ("japanese".equals(localeString)) return Locale.JAPANESE; if ("korea".equals(localeString)) return Locale.KOREA; if ("korean".equals(localeString)) return Locale.KOREAN; if ("prc".equals(localeString)) return Locale.PRC; if ("simplified_chinese".equals(localeString)) return Locale.SIMPLIFIED_CHINESE; if ("taiwan".equals(localeString)) return Locale.TAIWAN; if ("traditional_chinese".equals(localeString)) return Locale.TRADITIONAL_CHINESE; if ("uk".equals(localeString)) return Locale.UK; if ("us".equals(localeString)) return Locale.US; String parts[] = localeString.split("_", -1); if (parts.length == 1) return new Locale(parts[0]); else if (parts.length == 2) return new Locale(parts[0], parts[1]); else return new Locale(parts[0], parts[1], parts[2]); }
From source file:app.service.CaptchaService.java
protected void sendEmail(String email, String authCode) throws MessagingException, UnsupportedEncodingException { MimeMessage mimeMessage = mMailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, "UTF-8"); helper.setSubject(" LsPush "); helper.setFrom(serverEmail, serverName); helper.setTo(email);/*from w w w.j ava 2s . c o m*/ String authLink = String.format("%s/user/auth?auth_code=%s", serverUrl, authCode); final Context ctx = new Context(Locale.CHINA); ctx.setVariable("serverUrl", serverUrl); ctx.setVariable("serverName", serverName); ctx.setVariable("email", email); ctx.setVariable("authCode", authCode); ctx.setVariable("authLink", authLink); String html = mTemplateEngine.process("lspush_captcha_email", ctx); helper.setText(html, true); mMailSender.send(mimeMessage); }
From source file:HtmlUtil.java
/** * Finds first index of a substring in the given source string with ignored * case. This seems to be the fastest way doing this, with common string * length and content (of course, with no use of Boyer-Mayer type of * algorithms). Other implementations are slower: getting char array frist, * lowercasing the source string, using String.regionMatch etc. * * @param src source string for examination * @param subS substring to find//from w w w. j ava 2s . c o m * @param startIndex starting index from where search begins * * @return index of founded substring or -1 if substring is not found */ public static int indexOfIgnoreCase(String src, String subS, int startIndex) { String sub = subS.toLowerCase(Locale.CHINA); int sublen = sub.length(); int total = src.length() - sublen + 1; for (int i = startIndex; i < total; i++) { int j = 0; while (j < sublen) { char source = Character.toLowerCase(src.charAt(i + j)); if (sub.charAt(j) != source) { break; } j++; } if (j == sublen) { return i; } } return -1; }
From source file:cn.edu.nuc.seeworld.fg.ColorFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CAMERA && resultCode == Activity.RESULT_OK && null != data) { String sdState = Environment.getExternalStorageState(); if (!sdState.equals(Environment.MEDIA_MOUNTED)) { return; }/*w w w . j av a2s .c om*/ String name = DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg"; Bundle bundle = data.getExtras(); //???? Bitmap bitmap = (Bitmap) bundle.get("data"); FileOutputStream fout = null; File file = new File("/sdcard/pintu/"); file.mkdirs(); String filename = file.getPath() + name; try { fout = new FileOutputStream(filename); pic_path = filename; bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { try { fout.flush(); fout.close(); } catch (IOException e) { e.printStackTrace(); } } pic_imageView.setImageBitmap(bitmap); pic_imageView.setVisibility(View.VISIBLE); } if (requestCode == PHOTO && resultCode == Activity.RESULT_OK && null != data) { Uri selectedImage = data.getData(); String[] filePathColumns = { MediaStore.Images.Media.DATA }; Cursor c = this.getActivity().getContentResolver().query(selectedImage, filePathColumns, null, null, null); c.moveToFirst(); int columnIndex = c.getColumnIndex(filePathColumns[0]); String picturePath = c.getString(columnIndex); c.close(); //? Log.d("SEEWORLDTAG", picturePath); Bitmap bitmap = BitmapFactory.decodeFile(picturePath); pic_path = picturePath; pic_imageView.setImageBitmap(bitmap); pic_imageView.setVisibility(View.VISIBLE); } }
From source file:org.talend.dataquality.statistics.datetime.CustomDateTimePatternManagerTest.java
@Test public void testDateWithLocaleFR() { // simulate a JVM Locale.setDefault(Locale.FRANCE); final List<String> pattern = Collections.<String>singletonList("MMMM d ?? yyyy"); final String[] dates = new String[] { "January 9 ?? 1970", // EN "janvier 9 ?? 1970", // FR "Januar 9 ?? 1970", // DE " 9 ?? 1970", // CN };/*from ww w . ja v a 2s .co m*/ final boolean[] EXPECTED_IS_DATE_DEFAULT = new boolean[] { true, false, false, false }; final boolean[] EXPECTED_IS_DATE_US = new boolean[] { true, false, false, false }; final boolean[] EXPECTED_IS_DATE_FR = new boolean[] { true, true, false, false }; final boolean[] EXPECTED_IS_DATE_DE = new boolean[] { true, false, true, false }; final boolean[] EXPECTED_IS_DATE_CN = new boolean[] { true, false, false, true }; // final String[] EXPECTED_PATTERN_STRING = new String[] { "", }; StringBuilder sb = new StringBuilder("\n"); sb.append("-------------- JVM Locale: " + Locale.getDefault().toString() + " ------\n"); sb.append("Input \\ UserLocale\tN/A\tEN\tFR\tDE\tCN\n"); for (int i = 0; i < dates.length; i++) { sb.append(dates[i]).append(" \t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.US)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.FRANCE)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.GERMANY)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.CHINA)).append("\t"); sb.append("\n"); assertEquals(EXPECTED_IS_DATE_DEFAULT[i], CustomDateTimePatternManager.isDate(dates[i], pattern)); assertEquals(EXPECTED_IS_DATE_US[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.US)); assertEquals(EXPECTED_IS_DATE_FR[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.FRANCE)); assertEquals(EXPECTED_IS_DATE_DE[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.GERMANY)); assertEquals(EXPECTED_IS_DATE_CN[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.CHINA)); } LOGGER.info(sb.toString()); }
From source file:com.fengduo.bee.commons.util.DateViewTools.java
private static SimpleDateFormat getFormat(String key) { HashMap<String, SimpleDateFormat> map = formatHolder.get(); if (map == null) { map = new HashMap<String, SimpleDateFormat>(2); formatHolder.set(map);// ? }/* w w w.ja v a 2s .c o m*/ SimpleDateFormat simpleDateFormat = map.get(key); if (simpleDateFormat == null) { simpleDateFormat = new SimpleDateFormat(key, Locale.CHINA); map.put(key, simpleDateFormat); formatHolder.set(map);// ? } return simpleDateFormat; }
From source file:org.apache.tiles.definition.TestUrlDefinitionsFactory.java
/** * Tests the addDefinitions method under normal * circumstances.//from www. j ava 2 s . c om * * @throws Exception If something goes wrong. */ @SuppressWarnings("unchecked") public void testReadByLocale() throws Exception { MockPublicUrlDefinitionsFactory factory = new MockPublicUrlDefinitionsFactory(); // Set up multiple data sources. URL url1 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs1.xml"); assertNotNull("Could not load defs1 file.", url1); URL url2 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs2.xml"); assertNotNull("Could not load defs2 file.", url2); URL url3 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs3.xml"); assertNotNull("Could not load defs3 file.", url3); factory.init(Collections.EMPTY_MAP); factory.addSource(url1); factory.addSource(url2); factory.addSource(url3); // Parse files. Definitions definitions = factory.readDefinitions(); factory.addDefinitions(definitions, new MockOnlyLocaleTilesContext(Locale.US)); factory.addDefinitions(definitions, new MockOnlyLocaleTilesContext(Locale.FRENCH)); assertNotNull("test.def1 definition not found.", definitions.getDefinition("test.def1")); assertNotNull("test.def1 US definition not found.", definitions.getDefinition("test.def1", Locale.US)); assertNotNull("test.def1 France definition not found.", definitions.getDefinition("test.def1", Locale.FRENCH)); assertNotNull("test.def1 China should return default.", definitions.getDefinition("test.def1", Locale.CHINA)); assertEquals("Incorrect default country value", "default", definitions.getDefinition("test.def1").getAttribute("country").getValue()); assertEquals("Incorrect US country value", "US", definitions.getDefinition("test.def1", Locale.US).getAttribute("country").getValue()); assertEquals("Incorrect France country value", "France", definitions.getDefinition("test.def1", Locale.FRENCH).getAttribute("country").getValue()); assertEquals("Incorrect Chinese country value (should default)", "default", definitions.getDefinition("test.def1", Locale.CHINA).getAttribute("country").getValue()); }
From source file:org.talend.dataquality.statistics.datetime.CustomDateTimePatternManagerTest.java
@Test public void testDateWithLocaleDE() { // simulate a JVM Locale.setDefault(Locale.GERMANY); final List<String> pattern = Collections.<String>singletonList("MMMM d ?? yyyy"); final String[] dates = new String[] { "January 9 ?? 1970", // EN "janvier 9 ?? 1970", // FR "Januar 9 ?? 1970", // DE " 9 ?? 1970", // CN };/*from w ww . j a v a2 s . c om*/ final boolean[] EXPECTED_IS_DATE_DEFAULT = new boolean[] { true, false, false, false }; final boolean[] EXPECTED_IS_DATE_US = new boolean[] { true, false, false, false }; final boolean[] EXPECTED_IS_DATE_FR = new boolean[] { true, true, false, false }; final boolean[] EXPECTED_IS_DATE_DE = new boolean[] { true, false, true, false }; final boolean[] EXPECTED_IS_DATE_CN = new boolean[] { true, false, false, true }; // final String[] EXPECTED_PATTERN_STRING = new String[] { "", }; StringBuilder sb = new StringBuilder("\n"); sb.append("-------------- JVM Locale: " + Locale.getDefault().toString() + " ------\n"); sb.append("Input \\ UserLocale\tN/A\tEN\tFR\tDE\tCN\n"); for (int i = 0; i < dates.length; i++) { sb.append(dates[i]).append(" \t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.US)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.FRANCE)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.GERMANY)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.CHINA)).append("\t"); sb.append("\n"); assertEquals(EXPECTED_IS_DATE_DEFAULT[i], CustomDateTimePatternManager.isDate(dates[i], pattern)); assertEquals(EXPECTED_IS_DATE_US[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.US)); assertEquals(EXPECTED_IS_DATE_FR[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.FRANCE)); assertEquals(EXPECTED_IS_DATE_DE[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.GERMANY)); assertEquals(EXPECTED_IS_DATE_CN[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.CHINA)); } LOGGER.info(sb.toString()); }
From source file:com.qawaa.gui.EventWebScanGUI.java
/** * /*from w w w .j a v a 2 s .c om*/ */ private void initGUI() { try { setSize(900, 600); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { optionMenus = new JMenu(); jMenuBar1.add(optionMenus); optionMenus.setText(CONTEXT.getMessage("gobal.menu.option", null, Locale.CHINA)); { exitMenuItem = new JMenuItem(); optionMenus.add(exitMenuItem); exitMenuItem.setText(CONTEXT.getMessage("gobal.menu.option.quit", null, Locale.CHINA)); exitMenuItem.setMnemonic(KeyEvent.VK_Q); exitMenuItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.ALT_MASK, false)); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { windowsClosed(); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.lcl6.cn.imagepickerl.AndroidImagePicker.java
/** * create a file to save photo/*from w w w . jav a2 s.co m*/ * @param ctx * @return */ private File createImageSaveFile(Context ctx) { if (Util.isStorageEnable()) { // File pic = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (!pic.exists()) { pic.mkdirs(); } String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()); String fileName = "IMG_" + timeStamp; File tmpFile = new File(pic, fileName + ".jpg"); mCurrentPhotoPath = tmpFile.getAbsolutePath(); Log.i(TAG, "=====camera path:" + mCurrentPhotoPath); return tmpFile; } else { //File cacheDir = ctx.getCacheDir(); File cacheDir = Environment.getDataDirectory(); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()); String fileName = "IMG_" + timeStamp; File tmpFile = new File(cacheDir, fileName + ".jpg"); mCurrentPhotoPath = tmpFile.getAbsolutePath(); Log.i(TAG, "=====camera path:" + mCurrentPhotoPath); return tmpFile; } }