List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
public static long string2Millis(String str, String pattern) { SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.getDefault()); long millis = 0; try {// w w w .j av a 2 s . co m millis = format.parse(str).getTime(); } catch (ParseException e) { Log.e("TAG", e.getMessage()); } return millis; }
From source file:Main.java
public static String getAddressFromLoc(Context pContext, double latitude, double longitude) throws IOException { Geocoder geocoder = new Geocoder(pContext, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1); String address = ""; if (addresses.get(0) != null) address = addresses.get(0).getAddressLine(0); String city = addresses.get(0).getLocality(); String zip = addresses.get(0).getPostalCode(); String country = addresses.get(0).getCountryName(); address = (address == null) ? "" : address; city = (city == null) ? "" : city; zip = (zip == null) ? "" : zip; country = (country == null) ? "" : country; return address + " " + city + " " + zip + " " + country; }
From source file:Main.java
public static Date convertStringDateToDate(String date) { try {/*from w w w . ja va2 s . c o m*/ if (date != null && date.compareTo("null") != 0 && date.compareTo("") != 0) { if (date.length() > 11) { return (Date) new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault()).parse(date); } else { return (Date) new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(date); } } } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String millis2String(long millis, String pattern) { return new SimpleDateFormat(pattern, Locale.getDefault()).format(new Date(millis)); }
From source file:Main.java
public static String getDeviceLocale() { return Locale.getDefault().getLanguage(); }
From source file:Main.java
public static String formatDate(Date date, String fmt) { return formatDate(date, fmt, Locale.getDefault()); }
From source file:Main.java
public static String GetLanguage() { return Locale.getDefault().getLanguage(); }
From source file:Main.java
public static boolean writeBmpToSDCard(Bitmap bmp, File file, int quality) { try {// ww w. j a v a 2s . c o m ByteArrayOutputStream baosm = new ByteArrayOutputStream(); if (file.getPath().toLowerCase(Locale.getDefault()).endsWith(".png")) { bmp.compress(Bitmap.CompressFormat.PNG, quality, baosm); } else { bmp.compress(Bitmap.CompressFormat.JPEG, quality, baosm); } byte[] bts = baosm.toByteArray(); if (file.exists()) { file.delete(); } file.createNewFile(); File tempFile = new File(file.getPath() + ".png"); FileOutputStream fosm = new FileOutputStream(tempFile); BufferedOutputStream bos = new BufferedOutputStream(fosm); bos.write(bts); bos.flush(); bos.close(); fosm.close(); tempFile.renameTo(file); return true; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
From source file:Main.java
public static String getSysDate() { Time t = new Time(); t.setToNow();/*from w ww . j a v a 2 s. c om*/ int year = t.year; int month = t.month + 1; int day = t.monthDay; int hour = t.hour; // 0-23 int minute = t.minute; int second = t.second; return String.format("%04d%02d%02d%02d%02d%02d", year, month, day, hour, minute, second, Locale.getDefault()); }
From source file:Main.java
public static void onCreate(Context context) { String lang = getPersistedData(context, Locale.getDefault().getLanguage()); setLocale(context, lang); }