List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:com.krawler.esp.utils.PropsLoader.java
public static Properties loadProperties(String name, ClassLoader loader) { if (name == null) throw new IllegalArgumentException("null input: name"); if (name.startsWith("/")) name = name.substring(1);//www .j av a 2s . c o m if (name.endsWith(SUFFIX)) name = name.substring(0, name.length() - SUFFIX.length()); Properties result = null; InputStream in = null; try { if (loader == null) loader = ClassLoader.getSystemClassLoader(); if (LOAD_AS_RESOURCE_BUNDLE) { name = name.replace('/', '.'); // Throws MissingResourceException on lookup failures: final ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault(), loader); result = new Properties(); for (Enumeration keys = rb.getKeys(); keys.hasMoreElements();) { final String key = (String) keys.nextElement(); final String value = rb.getString(key); result.put(key, value); } } else { name = name.replace('.', '/'); if (!name.endsWith(SUFFIX)) name = name.concat(SUFFIX); // Returns null on lookup failures: in = loader.getResourceAsStream(name); if (in != null) { result = new Properties(); result.load(in); // Can throw IOException } } } catch (Exception e) { logger.warn(e.getMessage(), e); result = null; } finally { if (in != null) try { in.close(); } catch (Throwable ignore) { logger.warn(ignore.getMessage(), ignore); } } if (THROW_ON_LOAD_FAILURE && (result == null)) { throw new IllegalArgumentException("could not load [" + name + "]" + " as " + (LOAD_AS_RESOURCE_BUNDLE ? "a resource bundle" : "a classloader resource")); } return result; }
From source file:com.arellomobile.android.push.request.versions.Version__1_2.java
@Override public Map<String, Object> getRegistrationUnregistrationData(Context context, String deviceRegistrationID) { HashMap<String, Object> data = new HashMap<String, Object>(); data.put("application", PreferenceUtils.getApplicationId(context)); data.put("hw_id", GeneralUtils.getDeviceUUID(context)); data.put("device_name", GeneralUtils.isTablet(context) ? "Tablet" : "Phone"); data.put("device_type", "3"); data.put("language", Locale.getDefault().getLanguage()); data.put("timezone", Calendar.getInstance().getTimeZone().getRawOffset() / 1000); // converting from // milliseconds to seconds data.put("device_id", deviceRegistrationID); return data;/* ww w. ja v a 2 s. co m*/ }
From source file:gov.nih.nci.caintegrator.domain.application.AbstractGenomicCriterion.java
/** * @param geneSymbol the geneSymbol to set *//*w w w . java2 s .c o m*/ public void setGeneSymbol(String geneSymbol) { this.geneSymbol = geneSymbol.toUpperCase(Locale.getDefault()); }
From source file:gov.nih.nci.caintegrator.common.DateUtil.java
/** * @param dateString string represent of Date * @return Date object/*from www .j a v a 2 s .c om*/ * @throws ParseException parsing exception */ public static Date createDate(String dateString) throws ParseException { if (StringUtils.isBlank(dateString)) { return null; } SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault()); return formatter.parse(formatDate(dateString)); }
From source file:com.arellomobile.android.push.request.versions.Version__1_3.java
@Override public Map<String, Object> getRegistrationUnregistrationData(Context context, String deviceRegistrationID) { HashMap<String, Object> data = new HashMap<String, Object>(); data.put("application", PreferenceUtils.getApplicationId(context)); data.put("hwid", GeneralUtils.getDeviceUUID(context)); data.put("device_name", GeneralUtils.isTablet(context) ? "Tablet" : "Phone"); data.put("device_type", "3"); data.put("language", Locale.getDefault().getLanguage()); data.put("timezone", Calendar.getInstance().getTimeZone().getRawOffset() / 1000); // converting from // milliseconds to seconds data.put("push_token", deviceRegistrationID); return data;/*from www. j a va2s . com*/ }
From source file:de.perdian.commons.lang.conversion.impl.converters.AbstractFormatConverter.java
@Override public B convert(A source) { Locale resolvedLocale = this.getLocaleContext() == null ? null : this.getLocaleContext().getLocale(); Locale useLocale = resolvedLocale == null ? Locale.getDefault() : resolvedLocale; F internalFormat = this.getFormat(); F useFormat = internalFormat == null ? this.resolveDefaultFormat(useLocale) : internalFormat; return this.convertUsingFormat(useFormat, source); }
From source file:es.tunelator.Start.java
/** * Tests if the default locale has specific support *///from ww w.j a v a 2 s . co m private static boolean isLocaleSupported() { Locale defaultLocale = Locale.getDefault(); String[] supportedLangs = Constants.SUPPORTED_LANGS; for (int i = 0; i < supportedLangs.length; i++) { if (defaultLocale.getLanguage().equals(new Locale(supportedLangs[i], "", "").getLanguage())) { return true; } } return false; }
From source file:com.microsoft.tfs.client.common.ui.config.UIClientConnectionAdvisor.java
/** * Creates a {@link UIClientConnectionAdvisor} that uses the current default * {@link Locale} and {@link TimeZone} for all * {@link ConnectionInstanceData}s./*from w ww . j a va 2s .c o m*/ */ public UIClientConnectionAdvisor() { super(Locale.getDefault(), TimeZone.getDefault()); }
From source file:com.isalnikov.utils.MessageHelper.java
public String getMessage(Object... params) { return getMessage(Locale.getDefault(), params); }
From source file:com.examples.with.different.packagename.StringUtilsEqualsIndexOfTest.java
@Test public void testContainsIgnoreCase_LocaleIndependence() { final Locale[] locales = { Locale.ENGLISH, new Locale("tr"), Locale.getDefault() }; final String[][] tdata = { { "i", "I" }, { "I", "i" }, { "\u03C2", "\u03C3" }, { "\u03A3", "\u03C2" }, { "\u03A3", "\u03C3" }, }; final String[][] fdata = { { "\u00DF", "SS" }, }; for (final Locale testLocale : locales) { Locale.setDefault(testLocale); for (int j = 0; j < tdata.length; j++) { assertTrue(Locale.getDefault() + ": " + j + " " + tdata[j][0] + " " + tdata[j][1], StringUtils.containsIgnoreCase(tdata[j][0], tdata[j][1])); }// www .ja va 2 s . c o m for (int j = 0; j < fdata.length; j++) { assertFalse(Locale.getDefault() + ": " + j + " " + fdata[j][0] + " " + fdata[j][1], StringUtils.containsIgnoreCase(fdata[j][0], fdata[j][1])); } } }