List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
public static String getFormatTime(String formatter, long time) { SimpleDateFormat format = new SimpleDateFormat(formatter, Locale.getDefault()); return format.format(new Date(time)); }
From source file:Main.java
public static String getFileExtenSion(File file) { String ex;/*from w w w .j ava2s. c o m*/ String filename; try { filename = file.getName(); ex = filename.substring(filename.lastIndexOf(".") + 1); } catch (Exception e) { return ""; } return ex.toLowerCase(Locale.getDefault()); }
From source file:Main.java
public static String date2String(Date date, String pattern) { return new SimpleDateFormat(pattern, Locale.getDefault()).format(date); }
From source file:Main.java
public static String stringDateToString(String format, String toFormat, String dateString) { ParsePosition position = new ParsePosition(0); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format, Locale.getDefault()); SimpleDateFormat StringDateFormat = new SimpleDateFormat(toFormat); Date dateValue = null;/*from w w w. java 2 s . c o m*/ String data = ""; try { dateValue = simpleDateFormat.parse(dateString, position); data = StringDateFormat.format(dateValue); } catch (Exception e) { e.printStackTrace(); } return data; }
From source file:Main.java
public static String getNameFromLocation(final double lat, final double lng, final Context context) throws IOException { final Geocoder gc = new Geocoder(context, Locale.getDefault()); if (Geocoder.isPresent()) { final List<Address> list = gc.getFromLocation(lat, lng, 1); if (list.size() > 0) { final Address address = list.get(0); return address.getAddressLine(0); }/*from w w w .jav a 2 s . c o m*/ } return "Fehler, bitte manuell eintragen"; }
From source file:Main.java
public static Calendar YYYYMMDDHHMMSSToCalendar(String str) { if (str != null) { Calendar cal = Calendar.getInstance(); try {/* w w w . j a v a 2s .c om*/ SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); cal.setTime(FORMAT.parse(str)); return cal; } catch (ParseException e) { return null; } } return null; }
From source file:Main.java
public static String getLanguage(Context context) { return getPersistedData(context, Locale.getDefault().getLanguage()); }
From source file:Main.java
public static Date parseToDate(String dateString, String pattern) { if (pattern == null || "".equals(pattern)) { pattern = "yyyy-MM-dd HH:mm:ss"; }// w w w . j av a2s.c om SimpleDateFormat formatter = new SimpleDateFormat(pattern, Locale.getDefault()); try { return formatter.parse(dateString); } catch (ParseException e) { } return new Date(); }
From source file:Main.java
public static String getLocalTimeFromUTC(String UTCTime) { java.util.Date UTCDate = null; String localTimeStr = null;/*from w w w .j a v a 2 s. c o m*/ SimpleDateFormat format = new SimpleDateFormat("HH:mm", Locale.getDefault()); try { UTCDate = format.parse(UTCTime); localTimeStr = format.format(UTCDate.getTime() + TimeZone.getDefault().getRawOffset()); } catch (ParseException e) { e.printStackTrace(); } return localTimeStr; }
From source file:Main.java
public static String getLanguage() { return Locale.getDefault().getLanguage(); }