List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:com.astamuse.asta4d.util.i18n.LocalizeUtil.java
public static final Locale defaultWhenNull(Locale locale) { if (locale == null) { locale = Context.getCurrentThreadContext().getCurrentLocale(); if (locale == null) { locale = Locale.getDefault(); if (locale == null) { locale = Locale.ROOT; }/*from w ww.jav a2 s .c om*/ } } return locale; }
From source file:net.sf.jasperreports.charts.util.CategoryLabelGenerator.java
public CategoryLabelGenerator(Map<Comparable<?>, Map<Comparable<?>, String>> labelsMap) { this(labelsMap, Locale.getDefault()); }
From source file:com.ddiiyy.xydz.xutils.util.OtherUtils.java
/** * @param context if null, use the default format * (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30). * @return/*from w w w . ja va 2 s. c o m*/ */ @SuppressLint("DefaultLocale") @SuppressWarnings("rawtypes") public static String getUserAgent(Context context) { String webUserAgent = null; if (context != null) { try { Class sysResCls = Class.forName("com.android.internal.R$string"); Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent"); Integer resId = (Integer) webUserAgentField.get(null); webUserAgent = context.getString(resId); } catch (Throwable ignored) { } } if (TextUtils.isEmpty(webUserAgent)) { webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1"; } Locale locale = Locale.getDefault(); StringBuffer buffer = new StringBuffer(); // Add version final String version = Build.VERSION.RELEASE; if (version.length() > 0) { buffer.append(version); } else { // default to "1.0" buffer.append("1.0"); } buffer.append("; "); final String language = locale.getLanguage(); if (language != null) { buffer.append(language.toLowerCase()); final String country = locale.getCountry(); if (country != null) { buffer.append("-"); buffer.append(country.toLowerCase()); } } else { // default to "en" buffer.append("en"); } // add the model for the release build if ("REL".equals(Build.VERSION.CODENAME)) { final String model = Build.MODEL; if (model.length() > 0) { buffer.append("; "); buffer.append(model); } } final String id = Build.ID; if (id.length() > 0) { buffer.append(" Build/"); buffer.append(id); } return String.format(webUserAgent, buffer, "Mobile "); }
From source file:net.sf.jasperreports.charts.util.XYDatasetLabelGenerator.java
public XYDatasetLabelGenerator(Map<Comparable<?>, Map<Number, String>> labelsMap) { this(labelsMap, Locale.getDefault()); }
From source file:com.amazonaws.tvmclient.TVMClient.java
public TVMClient(String endpoint, boolean useSSL, String accountId, String accountSecret, String deviceId, String cryptoKey, String deviceNick, String user, String password) { this.endpoint = this.getEndpointDomainName(endpoint.toLowerCase(Locale.getDefault())); this.useSSL = useSSL; this.accountId = accountId; this.accountSecret = accountSecret; this.deviceId = deviceId; this.cryptoKey = cryptoKey; this.deviceNick = deviceNick; this.user = user; this.password = password; }
From source file:com.frostwire.android.gui.views.SuggestionsAdapter.java
private static String buildSuggestionsUrl() { String lang = Locale.getDefault().getLanguage(); if (StringUtils.isNullOrEmpty(lang)) { lang = "en"; }// ww w. j a v a 2 s .c o m return "http://suggestqueries.google.com/complete/search?output=firefox&hl=" + Locale.getDefault() + "&q=%s"; }
From source file:FirstClass.java
public String getString() { return Locale.getDefault().getDisplayName(); }
From source file:com.bibisco.manager.LocaleManager.java
private Locale initLocale() { Locale lLocale = null;//from w w w . j av a 2s.c o m mLog.debug("Start initLocale()"); PropertiesManager lPropertiesManager = PropertiesManager.getInstance(); String lStrLocale = lPropertiesManager.getProperty("locale"); if (StringUtils.isNotBlank(lStrLocale)) { String[] lStrLocaleSplit = lStrLocale.split("_"); lLocale = new Locale(lStrLocaleSplit[0], lStrLocaleSplit[1]); } else { lLocale = Locale.getDefault(); lPropertiesManager.updateProperty("locale", lLocale.toString()); } mLog.debug("End initLocale()"); return lLocale; }
From source file:com.lianggzone.freemarkerutils.utils.FreeMarkerFactory.java
/** * ?ftl?,???HTML//from www .ja v a 2s . co m * @param ftlPath FTL?,["c:/liang/template.ftl"] * @param filePath ?HMTL["d:/liang/lianggzone.html"] * @param data Map? * @param isCreate4NoExists ?? * @return */ public static boolean createHTML(String ftlPath, String filePath, Map<String, Object> data, boolean isCreate4NoExists) throws IOException { String fileDir = StringUtils.substringBeforeLast(filePath, "/"); // ?HMTL // String fileName = StringUtils.substringAfterLast(filePath, "/"); // ?HMTL?? String ftlDir = StringUtils.substringBeforeLast(ftlPath, "/"); // ?FTL String ftlName = StringUtils.substringAfterLast(ftlPath, "/"); // ?FTL?? //? if (isCreate4NoExists) { File realDirectory = new File(fileDir); if (!realDirectory.exists()) { realDirectory.mkdirs(); } } // step1 ?freemarker? Configuration freemarkerCfg = new Configuration(Configuration.VERSION_2_3_23); // step2 freemarker??() freemarkerCfg.setDirectoryForTemplateLoading(new File(ftlDir)); // step3 freemarker?? freemarkerCfg.setEncoding(Locale.getDefault(), CharEncoding.UTF_8); // step4 freemarker? Template template = freemarkerCfg.getTemplate(ftlName, CharEncoding.UTF_8); // step5 ?IO? try (Writer writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(new File(filePath)), CharEncoding.UTF_8))) { writer.flush(); // step6 ?? template.process(data, writer); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:com.relicum.ipsum.Locale.LocaleManager.java
/** * Get the current locale currently set. * * @return locale in tag format of the current locale set. *///w w w . jav a 2 s . c om public String getLocale() { return Locale.getDefault().toLanguageTag(); }