List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
public static String GetDeviceLanguage() { String Language = "zh_CN"; if (Locale.getDefault().getLanguage().equals("en")) { Language = "en_US"; }/*from w ww . ja v a2 s .co m*/ return Language; }
From source file:Main.java
private static String i(Context context) { if (h == null) { String s = (new WebView(context)).getSettings().getUserAgentString(); if (s == null || s.length() == 0 || s.equals("Java0")) { String s1 = System.getProperty("os.name", "Linux"); String s2 = (new StringBuilder()).append("Android ").append(android.os.Build.VERSION.RELEASE) .toString();/*from w ww . j a va2s . co m*/ Locale locale = Locale.getDefault(); String s3 = locale.getLanguage().toLowerCase(); if (s3.length() == 0) s3 = "en"; String s4 = locale.getCountry().toLowerCase(); String s5; String s6; if (s4.length() > 0) s5 = (new StringBuilder()).append(s3).append("-").append(s4).toString(); else s5 = s3; s6 = (new StringBuilder()).append(Build.MODEL).append(" Build/").append(Build.ID).toString(); s = (new StringBuilder()).append("Mozilla/5.0 (").append(s1).append("; U; ").append(s2).append("; ") .append(s5).append("; ").append(s6).append(") AppleWebKit/0.0 (KHTML, like ") .append("Gecko) Version/0.0 Mobile Safari/0.0").toString(); } h = (new StringBuilder()).append(s).append(" (Mobile; ").append("afma-sdk-a-v").append("4.1.0") .append(")").toString(); } return h; }
From source file:Main.java
/** * Parses XML datetime object to Date object * * @param xmlDateTime XML Datetime as a String * @return Datetime object/*from ww w . j av a2s . com*/ * @throws ParseException if Parsing exception occurred */ public static Date parseXmlDateTime(String xmlDateTime) { Date parsedDate = new Date(); try { xmlDateTime = xmlDateTime.replace("Z", "+0000"); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault()); parsedDate = dateFormat.parse(xmlDateTime); return parsedDate; } catch (ParseException e) { e.printStackTrace(); } return parsedDate; }
From source file:Main.java
public static boolean isChinese() { return Locale.getDefault().getLanguage().startsWith(Locale.CHINESE.getLanguage()); }
From source file:Main.java
/** * @param time time stamp/* ww w. ja va 2s . c o m*/ * @param formatType time conversion format * @return is it the day */ public static boolean isToday(long time, @Nullable String formatType) { if (time == 0) { long currentTime = new Date().getTime(); time = currentTime - 86400000; } if (formatType == null) { formatType = "yyyy-MM-dd"; } Date dateOld = new Date(time); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formatType, Locale.getDefault()); if (simpleDateFormat.format(dateOld).equals(simpleDateFormat.format(new Date()))) { return true; } else { return false; } }
From source file:Main.java
public static NdefRecord createTextRecord(String payload, boolean encodeInUtf8) { byte[] langBytes = Locale.getDefault().getLanguage().getBytes(Charset.forName("US-ASCII")); Charset utfEncoding = encodeInUtf8 ? Charset.forName("UTF-8") : Charset.forName("UTF-16"); byte[] textBytes = payload.getBytes(utfEncoding); int utfBit = encodeInUtf8 ? 0 : (1 << 7); char status = (char) (utfBit + langBytes.length); byte[] data = new byte[1 + langBytes.length + textBytes.length]; data[0] = (byte) status; System.arraycopy(langBytes, 0, data, 1, langBytes.length); System.arraycopy(textBytes, 0, data, 1 + langBytes.length, textBytes.length); NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], data); return record; }
From source file:Main.java
private static String getLocale() { final Locale locale = Locale.getDefault(); return locale.getLanguage() + "-" + locale.getCountry().toLowerCase(); }
From source file:Main.java
/** * Format a phone number based on the number's country code, falling * back to the format defined by the user's current locale. This is * to replace calling {@link PhoneNumberUtils#formatNumber(String)}, * which was deprecated in the LOLLIPOP release. * * @see PhoneNumberUtils#formatNumber(String, String) * @param number The phone number to be formatted * @return The phone number, formatted based on the country code or * user's locale.//from ww w . ja v a2 s . c o m */ public static String formatNumber(String number) { return PhoneNumberUtils.formatNumber(number, Locale.getDefault().getCountry()); }
From source file:Main.java
public static String getLanguageEnv() { Locale l = Locale.getDefault(); String language = l.getLanguage(); String country = l.getCountry().toLowerCase(); if ("zh".equalsIgnoreCase(language)) { if ("cn".equals(country)) { language = "zh-CN"; } else if ("tw".equals(country)) { language = "zh-TW"; }/*from w w w .jav a 2 s.c o m*/ } return language; }
From source file:Main.java
/** * Returns true if and only enabling adaptive playback is unsafe. On some * device / os combinations, enabling it causes decoded frames to be * unusable. For example, the S3 on 4.4.2 returns black and white, tiled * frames when this is enabled./*from w w w.j a va 2 s . co m*/ */ private static boolean isAdaptivePlaybackBlacklisted(String mime) { if (!mime.equals("video/avc") && !mime.equals("video/avc1")) { return false; } if (!Build.VERSION.RELEASE.equals("4.4.2")) { return false; } if (!Build.MANUFACTURER.toLowerCase(Locale.getDefault()).equals("samsung")) { return false; } return Build.MODEL.startsWith("GT-I9300") || // S3 (I9300 / I9300I) Build.MODEL.startsWith("SCH-I535"); // S3 }