List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
public static String millis2String(long millis) { return new SimpleDateFormat(DEFAULT_PATTERN, Locale.getDefault()).format(new Date(millis)); }
From source file:Main.java
public static long getTimeLong(String pattern, String dateString) { try {/*w ww. j a v a 2 s. co m*/ Date date = new SimpleDateFormat(pattern, Locale.getDefault()).parse(dateString); return date.getTime(); } catch (ParseException e) { e.printStackTrace(); } return -1; }
From source file:Main.java
public static String formatTimestamp(long millis) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); Date date = new Date(millis); return dateFormat.format(date); }
From source file:Main.java
public static String getCalendarString(Calendar dateTime) { // example: 24 May 2014, 10:13 PM SimpleDateFormat format = new SimpleDateFormat("d MMMM yyyy, h:mm a", Locale.getDefault()); return format.format(dateTime.getTime()); }
From source file:Main.java
public static boolean isEmulator() { return "sdk".equals(Build.PRODUCT) || "google_sdk".equals(Build.PRODUCT) || "generic".equals(Build.BRAND.toLowerCase(Locale.getDefault())); }
From source file:Main.java
public static String convertUnixToString(long unixTimeInMillis) { Date time = new Date(unixTimeInMillis * 1000); String timeString = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()).format(time); return timeString; }
From source file:Main.java
public static String parseDateToString(Date date_received) { //2014-06-28 14:56:59 SimpleDateFormat dateFormat_received = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss", Locale.getDefault()); String date_string = null;//from w w w. j a va2 s . c om date_string = dateFormat_received.format(date_received); return date_string; }
From source file:Main.java
public static int getDatePart(Date date, int part) { if (date == null) return 0; Calendar cal = Calendar.getInstance(Locale.getDefault()); cal.setTime(date);//from www . j a v a 2 s. c o m return cal.get(part); }
From source file:Main.java
public static String dumpLocationInfo(Location loc) { if (loc == null) { return "Location null or empty"; }//w ww .j a v a 2 s.co m return String.format(Locale.getDefault(), "lat: %f, lng: %f, acc: %f, provider: %s", loc.getLatitude(), loc.getLongitude(), loc.getAccuracy(), loc.getProvider()); }
From source file:Main.java
public static String getNumberTime(long time_second) { long seconds = time_second % 60; long minutes = (time_second / 60) % 60; long hours = time_second / 3600; Formatter formatter = new Formatter(null, Locale.getDefault()); return formatter.format("%02d:%02d:%02d", hours, minutes, seconds).toString(); }