List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
private static File getOutputMediaFile(int type) { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), ""); if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("failed", "Oops! Failed create " + "Alumni Space Picture" + " directory"); return null; }/*from w w w .j av a2s. c o m*/ } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); File mediaFile; if (type == 10) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); } else { return null; } return mediaFile; }
From source file:Main.java
public static int getCurrentNetType(Context context) { int result = NETTYPE_NONE; NetworkInfo localNetworkInfo = getCurrentActiveNetworkInfo(context); if (localNetworkInfo == null) { return result; }// w ww.j ava 2s .com if (localNetworkInfo.getState() == NetworkInfo.State.CONNECTED) { if (localNetworkInfo.getType() == 1) { result = NETTYPE_WIFI; } else if (localNetworkInfo.getType() == 0) { String subTypeName = localNetworkInfo.getSubtypeName().toUpperCase(Locale.getDefault()); if (subTypeName.indexOf("GPRS") > 1) { result = NETTYPE_MOBILE_GPRS; } else if (subTypeName.indexOf("EDGE") > 1) { result = NETTYPE_MOBILE_EDGE; } else { result = NETTYPE_MOBILE_3G; } } else { result = NETTYPE_UNKNOW; } } else if (localNetworkInfo.getState() == NetworkInfo.State.CONNECTING) { result = NETTYPE_UNKNOW; System.out.println("connecting " + localNetworkInfo.getType()); } return result; }
From source file:Main.java
public static File getOutputMediaFile() { // External sdcard location File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), IMAGE_DIRECTORY_NAME);/*from w ww .ja v a 2s . com*/ // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d(IMAGE_DIRECTORY_NAME, "Oops! Failed create " + IMAGE_DIRECTORY_NAME + " directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); File mediaFile; mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); return mediaFile; }
From source file:Main.java
private static Method getBooleanColumnGetMethod(Class<?> entityType, final String fieldName, String suffix) { String methodName = "is" + fieldName.substring(0, 1).toUpperCase(Locale.getDefault()) + fieldName.substring(1) + suffix; if (isStartWithIs(fieldName)) { methodName = fieldName + suffix; }//www . j a v a2 s . c o m try { return entityType.getDeclaredMethod(methodName); } catch (NoSuchMethodException e) { Log.d("L", methodName + " not exist"); } return null; }
From source file:Main.java
/** * check if the pair is [UTF-16,UTF-16LE] [UTF-32, UTF-32LE],[UTF-16,UTF-16BE] [UTF-32, * UTF-32BE] etc./* w w w. j ava 2 s. co m*/ * * @param enc1 encoding style * @param enc2 encoding style * @return true if the encoding styles are compatible, or false otherwise */ private static boolean compatibleEncodings(String enc1, String enc2) { enc1 = enc1.toLowerCase(Locale.getDefault()); enc2 = enc2.toLowerCase(Locale.getDefault()); if (enc1.endsWith("be") || enc1.endsWith("le")) { enc1 = enc1.substring(0, enc1.length() - 2); } if (enc2.endsWith("be") || enc2.endsWith("le")) { enc2 = enc2.substring(0, enc2.length() - 2); } return enc1.equals(enc2); }
From source file:Main.java
/*** * Fetch the estimate travel time to the indicated target * @param distance - how far to the target * @param speed - how fast we are moving * @param bearing - direction to target//from w ww . j a v a 2 s .c o m * @param heading - direction of movement * @return String - "HH:MM" time to the target */ public static String calculateEte(double distance, double speed, double bearing, double heading) { // Fetch the eteRaw value int eteRaw = fetchRawEte(distance, speed, bearing, heading); // If no speed or an invalid eteRaw, then return the empty display value if (0 == speed || eteRaw == -1) { return "--:--"; } // Break the eteRaw out into hours and minutes int eteHr = eteRaw / 100; int eteMin = eteRaw % 100; // Hours greater than 99 are not displayable if (eteHr > 99) { return "XX:XX"; } // Format the hours and minutes en router String hr = String.format(Locale.getDefault(), "%02d", eteHr); String min = String.format(Locale.getDefault(), "%02d", eteMin); // BUit the string for return return hr + ":" + min; }
From source file:Main.java
/** * Converte a Locale object to an xmlLang String * @param locale/*from w ww .j a va 2s . c om*/ * @return String of the form <locale.getLanguage()>-<locale.getCountry()> */ private static String localeToXmlLang(Locale locale) { if (locale == null) { return Locale.getDefault().getLanguage() + "-" + Locale.getDefault().getCountry(); } String lang = locale.getLanguage(); String countryCode = locale.getCountry(); if (countryCode == null || countryCode.length() == 0) { return lang; } else { return new String(lang + "-" + countryCode); } }
From source file:Main.java
public static Date getDate(String t, String pattern) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.getDefault()); try {//www .j a v a2 s . com Date date = dateFormat.parse(t); Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.setTime(date); return date; } catch (ParseException e) { return null; } }
From source file:Main.java
/** * Creates the temporary image file in the cache directory. * * @return The temporary image file./*from ww w . jav a 2 s . c o m*/ * @throws IOException Thrown if there is an error creating the file */ static File createTempImageFile(Context context) throws IOException { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = context.getExternalCacheDir(); return File.createTempFile(imageFileName, /* prefix */ ".jpg", /* suffix */ storageDir /* directory */ ); }
From source file:Main.java
public static String getUserLanguageCode(Context context) { return Locale.getDefault().getLanguage(); }