List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
public static String getSpeedString(float bytesPerMillisecond) { return String.format(Locale.getDefault(), "%.2f", bytesPerMillisecond * 1000 / 1024); }
From source file:Main.java
public static String getTime(long date) { final String timeFormatString = "h:mm "; DateFormat df = new SimpleDateFormat(timeFormatString, Locale.getDefault()); Date d = new Date(date); return df.format(d); }
From source file:Main.java
public static Locale getCurrent() { return Locale.getDefault(); }
From source file:Main.java
public static String getCurrentLanguage() { return Locale.getDefault().getLanguage(); }
From source file:PropertyLoader.java
public static Properties loadProperties(String name, ClassLoader loader) throws Exception { if (name.startsWith("/")) name = name.substring(1);/*from w w w. j a va 2 s. c o m*/ if (name.endsWith(SUFFIX)) name = name.substring(0, name.length() - SUFFIX.length()); Properties result = new Properties(); InputStream in = null; if (loader == null) loader = ClassLoader.getSystemClassLoader(); if (LOAD_AS_RESOURCE_BUNDLE) { name = name.replace('/', '.'); ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault(), loader); for (Enumeration keys = rb.getKeys(); keys.hasMoreElements();) { result.put((String) keys.nextElement(), rb.getString((String) keys.nextElement())); } } else { name = name.replace('.', '/'); if (!name.endsWith(SUFFIX)) name = name.concat(SUFFIX); in = loader.getResourceAsStream(name); if (in != null) { result = new Properties(); result.load(in); // can throw IOException } } in.close(); return result; }
From source file:io.dacopancm.oraclesp.Helper.java
/** * * @param line yyyy-MM-dd HH:mm/* w ww .jav a2 s . c o m*/ * @return */ public static Date stringToDate(String line) { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()); Date date = null; try { date = format.parse(line); } catch (ParseException e) { log.error("Lo sentimos, eso no es vlido. Por favor reintente."); } return date; }
From source file:Main.java
public static int getLanguageValue() { int lang = 0; Locale l = Locale.getDefault(); String language = l.getLanguage(); String country = l.getCountry().toLowerCase(); if ("zh".equalsIgnoreCase(language)) { if ("cn".equals(country)) { lang = 1;//from w w w . j a va 2s. co m } else if ("tw".equals(country)) { lang = 3; } } else { lang = 2; } return lang; }
From source file:Main.java
private static boolean isOver(final Date birthday) { boolean b = false; SimpleDateFormat sdf = new SimpleDateFormat("M-d", Locale.getDefault()); String md = sdf.format(birthday); Date now = new Date(); sdf = new SimpleDateFormat("yyyy", Locale.getDefault()); String y = sdf.format(now);/* w w w . jav a2 s. co m*/ String ymd = y + md; Date birDate = new Date(); try { birDate = sdf.parse(ymd); } catch (ParseException e) { e.printStackTrace(); } b = now.getTime() - birDate.getTime() > 0; return b; }
From source file:Main.java
public static CharSequence formatElapsedTime(long elapsedSeconds) { long hours = 0; long minutes = 0; long seconds = 0; if (elapsedSeconds >= 3600) { hours = elapsedSeconds / 3600;/*w ww . ja v a 2 s . c om*/ elapsedSeconds -= hours * 3600; } if (elapsedSeconds >= 60) { minutes = elapsedSeconds / 60; elapsedSeconds -= minutes * 60; } seconds = elapsedSeconds; Formatter f = new Formatter(new StringBuilder(10), Locale.getDefault()); if (hours > 0) { return f.format(ELAPSED_TIME_HMMSS, hours, minutes, seconds).toString(); } else { return f.format(ELAPSED_TIME_MMSS, minutes, seconds).toString(); } }
From source file:Main.java
/** * Converts time to a string, e.g. "1:59:30" * or "3.6" or "5:33"./*from w w w . j ava2 s . c o m*/ * * @param milliseconds Time in milliseconds since start of meeting * @return String formatted time interval string in "H:MM:SS" format. */ public static String timeToHMMSS(long milliseconds) { Log.v(TAG, "timeToHMMSS(" + milliseconds + ")"); int seconds = (int) (milliseconds % 60_000) / 1000; int minutes = (int) (milliseconds / 60_000) % 60; int hours = (int) (milliseconds / 3600_000); String hms; if (hours >= 1) { hms = String.format(Locale.getDefault(), "%d:%02d:%02d", hours, minutes, seconds); } else if (minutes >= 1) { hms = String.format(Locale.getDefault(), "%d:%02d", minutes, seconds); } else { hms = String.format(Locale.getDefault(), "%d", seconds); } return hms; }