List of usage examples for java.util Locale US
Locale US
To view the source code for java.util Locale US.
Click Source Link
From source file:com.salesmanager.core.module.impl.application.currencies.EURCurrencyModule.java
public BigDecimal getAmount(String amount) throws Exception { // Pattern pattern = // Pattern.compile("\\d{1,3}(?:(?:.\\d\\d\\d)*|\\d*)(?:\\,\\d\\d)?"); if (!amount.contains(",") && !amount.contains(".") && !amount.contains(",") && !amount.contains(" ")) { if (CurrencyModuleUtil.matchPositiveInteger(amount)) { BigDecimalValidator validator = CurrencyValidator.getInstance(); BigDecimal bdamount = validator.validate(amount, Locale.US); if (bdamount == null) { throw new ValidationException("Cannot parse " + amount); } else { return bdamount; }//from w w w. j a v a 2 s . co m } else { throw new ValidationException("Cannot parse " + amount); } } else { Matcher matcher = pattern.matcher(amount); if (matcher.matches()) { // switch comma and dots amount = amount.replaceAll(",", ":"); amount = amount.replaceAll("\\.", ","); amount = amount.replaceAll(":", "."); BigDecimalValidator validator = CurrencyValidator.getInstance(); // BigDecimal bdamount = validator.validate(amount, // Locale.GERMAN);//could do the job BigDecimal bdamount = validator.validate(amount, Locale.US); return bdamount; } else { throw new ValidationException("Cannot parse " + amount); } } }
From source file:com.strider.datadefender.extensions.BiographicFunctions.java
/** * Generates random 9-digit social insurance number * @return String//w ww . j av a 2 s . c om * @throws java.text.ParseException */ public java.sql.Date randomBirthDate() throws java.text.ParseException { final GregorianCalendar gc = new GregorianCalendar(); final int year = randBetween(1900, 2016); gc.set(GregorianCalendar.YEAR, year); final int dayOfYear = randBetween(1, gc.getActualMaximum(GregorianCalendar.DAY_OF_YEAR)); gc.set(GregorianCalendar.DAY_OF_YEAR, dayOfYear); final String birthDate = prependZero(gc.get(GregorianCalendar.DAY_OF_MONTH)) + "-" + prependZero(gc.get(GregorianCalendar.MONTH) + 1) + "-" + gc.get(GregorianCalendar.YEAR); log.debug("BirthDate:[" + birthDate + "]"); final DateFormat format = new SimpleDateFormat("dd-MM-yyyy", Locale.US); final java.sql.Date date = new java.sql.Date(format.parse(birthDate).getTime()); log.debug("Generated BirthDate:[" + date.toString() + "]"); return date; }
From source file:com.spotify.styx.model.Schedule.java
@JsonValue public String toJson() { return toString().toLowerCase(Locale.US); }
From source file:org.bfr.querytools.spectrumbridge.SpectrumBridgeQuery.java
private static HttpResponse channelQuery(double latitude, double longitude) throws ClientProtocolException, IOException { HttpClient client = createClient();/*from w ww. ja v a 2 s . c om*/ String queryUrl = String.format(Locale.US, "%s/channels/%s/%.6f/%.6f/?fccid=%s&serial=%d&type=%d", baseUrl, countryCode, latitude, longitude, fccId, serial, deviceType); HttpGet request = new HttpGet(queryUrl); request.addHeader("SBI-Sequence", "100"); request.addHeader("User-Agent", "HTMLGET 1.0"); return client.execute(request); }
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;//from ww w . j a v a 2 s .c o m 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:JDBCUtil.java
/** * Checks database metadata to see if a table exists. * Try UPPER, lower, and MixedCase, to see if the table is there. * * @param dbMetaData the database metadata to be used to look up this table * @param tableName the table name/* w ww .ja va 2s . c o m*/ * * @throws SQLException if an exception is encountered while accessing the database */ public boolean tableExists(DatabaseMetaData dbMetaData, String tableName) throws SQLException { return (tableExistsCaseSensitive(dbMetaData, tableName) || tableExistsCaseSensitive(dbMetaData, tableName.toUpperCase(Locale.US)) || tableExistsCaseSensitive(dbMetaData, tableName.toLowerCase(Locale.US))); }
From source file:de.interseroh.report.parameter.BirtConvertingTest.java
@Test public void testFromDateToString() throws Exception { LocaleContextHolder.setLocale(Locale.US); String converted = conversionService.convert(new Date(115, 0, 22), String.class); assertThat(converted, is("1/22/15")); }
From source file:com.acrutiapps.browser.tasks.HistoryBookmarksImportTask.java
@Override protected String doInBackground(String... params) { publishProgress(0, 0, 0);/*www.ja va 2 s.co m*/ File file = new File(Environment.getExternalStorageDirectory(), params[0]); if ((file != null) && (file.exists()) && (file.canRead())) { if (file.getName().toLowerCase(Locale.US).endsWith(".json")) { return readAsJSON(file); } else if (file.getName().toLowerCase(Locale.US).endsWith(".xml")) { return readAsXml(file); } else { return mContext.getString(R.string.HistoryBookmarksImportErrorInvalidFileFormat); } } else { return mContext.getString(R.string.HistoryBookmarksImportFileUnavailable); } }
From source file:com.mercandalli.android.apps.files.common.dialog.DialogCreateArticle.java
public DialogCreateArticle(final Activity activity, final IListener listener) { super(activity); this.mActivity = activity; this.setContentView(R.layout.dialog_create_article); this.setTitle("Create Article"); this.setCancelable(true); this.article_title_1 = (EditText) this.findViewById(R.id.title); this.article_content_1 = (EditText) this.findViewById(R.id.content); this.findViewById(R.id.request).setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a va 2 s . c o m public void onClick(View v) { SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US); dateFormatGmt.setTimeZone(TimeZone.getTimeZone("UTC")); String nowAsISO = dateFormatGmt.format(new Date()); JSONObject json = new JSONObject(); try { json.put("type", "article"); json.put("date_creation", nowAsISO); json.put("article_title_1", article_title_1.getText().toString()); json.put("article_content_1", article_content_1.getText().toString()); SimpleDateFormat dateFormatGmtTZ = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm'Z'", Locale.US); dateFormatGmtTZ.setTimeZone(TimeZone.getTimeZone("UTC")); nowAsISO = dateFormatGmtTZ.format(new Date()); List<StringPair> parameters = new ArrayList<>(); parameters.add(new StringPair("content", json.toString())); parameters.add(new StringPair("name", "ARTICLE_" + nowAsISO)); new TaskPost(mActivity, Constants.URL_DOMAIN + Config.ROUTE_FILE, new IPostExecuteListener() { @Override public void onPostExecute(JSONObject json, String body) { if (listener != null) { listener.execute(); } } }, parameters, "text/html; charset=utf-8").execute(); } catch (JSONException e) { Log.e(TAG, "DialogCreateArticle: failed to convert Json", e); } DialogCreateArticle.this.dismiss(); } }); DialogCreateArticle.this.show(); }
From source file:com.sawyer.advadapters.app.adapters.jsonadapter.UnitTestMovieAdapter.java
protected boolean isFilteredOut(MovieItem movie, CharSequence constraint) { return !movie.title.toLowerCase(Locale.US).contains(constraint.toString().toLowerCase(Locale.US)); }