List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
/** * Str format./*from w ww .ja va 2 s .co m*/ * * @param v * the v * @return the string */ public static String strFormat(double v) { double sv = round(v, 2); NumberFormat nf = NumberFormat.getInstance(Locale.getDefault()); return nf.format(sv); }
From source file:Main.java
public static String[] convertToARGB(int color) { String alpha = Integer.toHexString(Color.alpha(color)).toUpperCase(Locale.getDefault()); String red = Integer.toHexString(Color.red(color)).toUpperCase(Locale.getDefault()); String green = Integer.toHexString(Color.green(color)).toUpperCase(Locale.getDefault()); String blue = Integer.toHexString(Color.blue(color)).toUpperCase(Locale.getDefault()); // we want the strings with a leading 0 if needed return new String[] { ("00" + alpha).substring(alpha.length()), ("00" + red).substring(red.length()), ("00" + green).substring(green.length()), ("00" + blue).substring(blue.length()) }; }
From source file:Main.java
/** * Converts time to a string, with the minute and seconds always appearing. * E.g. "0:01" or "0:59" or 5:33" or "23:59:59". * * @param milliseconds Time in milliseconds since start of meeting * @return String formatted time interval string in "H:MM:SS" format. *///from ww w .java 2 s . c o m public static String timeToHMMSSMinuteMandatory(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 = String.format(Locale.getDefault(), "%d:%02d", minutes, seconds); if (hours >= 1) { hms = String.format(Locale.getDefault(), "%d:%02d:%02d", hours, minutes, seconds); } return hms; }
From source file:Main.java
public static Bundle bundleCalendar(Calendar cal, long minDate) { Bundle args = new Bundle(); if (cal == null) cal = Calendar.getInstance(Locale.getDefault()); ;//from ww w . j a va2 s . com args.putInt("year", cal.get(Calendar.YEAR)); args.putInt("month", cal.get(Calendar.MONTH)); args.putInt("day", cal.get(Calendar.DAY_OF_MONTH)); args.putInt("hour", cal.get(Calendar.HOUR_OF_DAY)); args.putInt("minute", cal.get(Calendar.MINUTE)); args.putLong("minDate", minDate); return args; }
From source file:Main.java
public static String getDateFormatString(String format) { Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat(format, Locale.getDefault()); //called without pattern return df.format(c.getTime()); }
From source file:Main.java
public static String getNowDateTime(String format) { SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.getDefault()); Date curDate = new Date(System.currentTimeMillis()); return formatter.format(curDate); }
From source file:Main.java
public static Date iso08601ParseDate(String input) throws java.text.ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz", Locale.getDefault()); if (input.endsWith("Z")) { input = input.substring(0, input.length() - 1) + "GMT-00:00"; } else {// www . jav a2s . c om int inset = 6; String start = input.substring(0, input.length() - inset); String end = input.substring(input.length() - inset, input.length()); input = start + "GMT" + end; } return sdf.parse(input); }
From source file:Main.java
public static JsonObject getCustomClientData(final Activity activity) { JsonObject data = new JsonObject(); Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w w w.jav a2 s . com int screenWidth = size.x; int screenHeight = size.y; data.add("ScreenWidth", new JsonPrimitive(screenWidth)); data.add("ScreenHeight", new JsonPrimitive(screenHeight)); JsonObject locale = new JsonObject(); try { locale.add("Default", new JsonPrimitive(Locale.getDefault().toString())); locale.add("DefaultDisplayLanguage", new JsonPrimitive(Locale.getDefault().getDisplayLanguage())); locale.add("DefaultDisplayCountry", new JsonPrimitive(Locale.getDefault().getDisplayCountry())); locale.add("DefaultDisplayName", new JsonPrimitive(Locale.getDefault().getDisplayName())); } catch (Exception exc) { } data.add("locale", locale); return data; }
From source file:Main.java
public static HashMap getParamMap(Map map) { HashMap hashmap = new HashMap(); hashmap.put(encodeStr("appid"), encodeStr("1uMqYWpHo3MoLH")); hashmap.put(encodeStr("callid"), encodeStr((new StringBuilder()).append("").append(generateCallId()).toString())); hashmap.put(encodeStr("v"), encodeStr("1.0")); hashmap.put(encodeStr("lang"), encodeStr(Locale.getDefault().getLanguage())); if (map != null) { hashmap.putAll(map);//from www . j a v a2 s . co m } hashmap.put("bd_sig", generateBgsid(hashmap)); return hashmap; }
From source file:Main.java
@SuppressWarnings("unused") public static String iso08601ToString(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz", Locale.getDefault()); TimeZone timeZone = TimeZone.getTimeZone("UTC"); sdf.setTimeZone(timeZone);/* w w w .j a v a 2 s . com*/ String output = sdf.format(date); int insetFirst = 9; int insetLast = 6; String retval = output.substring(0, output.length() - insetFirst) + output.substring(output.length() - insetLast, output.length()); return retval.replaceAll("UTC", "+00:00"); }