List of usage examples for java.lang String valueOf
public static String valueOf(double d)
From source file:Main.java
public static String asString(Object node, String key, String def) { Object value;//from w w w. ja va2s . com if ((node instanceof HashMap<?, ?>) && ((value = ((HashMap<?, ?>) node).get(key)) != null)) { return String.valueOf(value); } else { return def; } }
From source file:Main.java
public static void delete(Context context, int appWidgetId) { SharedPreferences prefs = context.getSharedPreferences("NETI_PREF", Context.MODE_PRIVATE); if (prefs != null) { SharedPreferences.Editor edit = prefs.edit(); if (edit != null) { edit.remove("NETI_BARVA" + String.valueOf(appWidgetId)); edit.commit();// ww w.j a va2s.com } } }
From source file:Main.java
public static String getVersionCode(Context context, int type) { try {/* w ww . j a v a 2 s .c o m*/ PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); if (type == 1) { return String.valueOf(pi.versionCode); } else { return pi.versionName; } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return null; } }
From source file:Main.java
/** * Obtiene el digito verificador del rut que se parsea * //from w w w. j a v a2s. c o m * @param rut * Rut a obtener digito verificador. * @return */ public static String getDV(int rut) { int M = 0, S = 1, T = rut; for (; T != 0; T /= 10) { S = (S + T % 10 * (9 - M++ % 6)) % 11; } char dv = (char) (S != 0 ? S + 47 : 75); return String.valueOf(dv); }
From source file:Main.java
public static void addErrorMap(String mes) { if (errorMap == null) { errorMap = new HashMap<String, String>(); }//from w w w. java2 s . c o m if (errorMap.containsKey(mes)) { int count = Integer.valueOf(errorMap.get(mes)); errorMap.remove(mes); errorMap.put(mes, String.valueOf(++count)); } else { errorMap.put(mes, "1"); } }
From source file:gov.nih.nci.eagle.web.ajax.DynamicListHelper.java
public static String createGenericList(String listType, List<String> list, String name) throws OperationNotSupportedException { try {/*from w ww .j a va2s . co m*/ String[] tps = CommonListFunctions.parseListType(listType); //tps[0] = ListType //tps[1] = ListSubType (if not null) ListType lt = ListType.valueOf(tps[0]); if (tps.length > 1 && tps[1] != null) { //create a list out of [1] ArrayList<ListSubType> lst = new ArrayList(); lst.add(ListSubType.valueOf(tps[1])); EAGLEListValidator lv = new EAGLEListValidator(ListType.valueOf(tps[0]), ListSubType.valueOf(tps[1]), list); return CommonListFunctions.createGenericList(lt, lst.get(0), list, name, lv); } else if (tps.length > 0 && tps[0] != null) { //no subtype, only a primary type - typically a PatientDID then EAGLEListValidator lv = new EAGLEListValidator(ListType.valueOf(tps[0]), list); return CommonListFunctions.createGenericList(lt, list, name, lv); } else { //no type or subtype, not good, force to clinical in catch throw new Exception(); } } catch (Exception e) { //try as a patient list as default, will fail validation if its not accepted return CommonListFunctions.createGenericList(ListType.PatientDID, list, name, new EAGLEListValidator(ListType.PatientDID, list)); } }
From source file:Main.java
public static List convertMapToList(Map map) { List list = new ArrayList(); Object[] o = ((HashMap) map).keySet().toArray(); Arrays.sort(o);/*from ww w .j a v a2 s . c om*/ for (int i = 0; i <= o.length - 1; i++) { if (map.containsKey(String.valueOf(o[i]))) { list.add(map.get(String.valueOf(o[i]))); } else { list.add(map.get("")); } } return list; }
From source file:Main.java
public static String getAppName(Context context, String packageName) { PackageManager pm = context.getPackageManager(); String appName = null;/*w w w. j a v a 2 s . co m*/ try { ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, 0); appName = String.valueOf(pm.getApplicationLabel(applicationInfo)); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return appName; }
From source file:Main.java
public static String getAppVersionCode(Context context) { int versionCode = 0; try {//from www .j a v a 2 s. c om versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } return String.valueOf(versionCode); }
From source file:Main.java
public static String formatDate(SimpleDateFormat format, Long time) { if (null == time || time <= 0) { return ""; }/*from ww w . j av a 2 s. c om*/ return format.format(new Date(String.valueOf(time).length() == 13 ? time : time * 1000)); }