List of usage examples for java.lang String valueOf
public static String valueOf(double d)
From source file:Main.java
/** * parse value to int/* ww w .ja v a2s. c o m*/ */ public static int toInt(Object value) { if (value instanceof Number) { return ((Number) value).intValue(); } return value == null ? 0 : toInt(String.valueOf(value)); }
From source file:Main.java
/** * parse value to char/* www . java 2 s.com*/ */ public static char toChar(Object value) { if (value instanceof Character) { return (Character) value; } return value == null ? '\0' : toChar(String.valueOf(value)); }
From source file:Main.java
public static void logBytes(byte[] ucPtr) { String s;/*from w w w . j a va 2s . c o m*/ final StringBuffer sb = new StringBuffer(); for (int i = 0; i < ucPtr.length; ++i) { if (0 == i) { s = ""; } else { s = ", "; } s += String.valueOf(ucPtr[i]); sb.append(s); } // LogUtil.amengLog().d("++++ " + "data=" + sb); }
From source file:Main.java
public static String list_to_nice_string(List<Object> cuisines) { String out = ""; for (Object aux : cuisines) { try {/*from w w w. j a v a2s . co m*/ JSONObject jsonObj = new JSONObject(String.valueOf(aux)); out = out + ", " + jsonObj.getString("name"); } catch (JSONException e) { e.printStackTrace(); } } if (out.length() > 4) { return out.substring(0, out.length() - 2); } else { return ""; } }
From source file:Main.java
public static String logBytes(byte[] ucPtr) { String s;/*from w w w.jav a 2 s .c o m*/ final StringBuffer sb = new StringBuffer(); for (int i = 0; i < ucPtr.length; ++i) { if (0 == i) { s = ""; } else { s = ", "; } s += String.valueOf(ucPtr[i]); sb.append(s); } return sb.toString(); }
From source file:Main.java
/** * parse value to byte/* ww w. j ava 2 s . c om*/ */ public static byte toByte(Object value) { if (value instanceof Number) { return ((Number) value).byteValue(); } return value == null ? 0 : toByte(String.valueOf(value)); }
From source file:Main.java
/** * parse value to long/* ww w .j ava2 s . co m*/ */ public static long toLong(Object value) { if (value instanceof Number) { return ((Number) value).longValue(); } return value == null ? 0 : toLong(String.valueOf(value)); }
From source file:Main.java
public static String getTodayDateString() { Calendar now = Calendar.getInstance(); int year = now.get(Calendar.YEAR); int month = now.get(Calendar.MONTH) + 1; int day = now.get(Calendar.DAY_OF_MONTH); String monthStr = String.valueOf(month); String dayStr = String.valueOf(day); if (month < 10) { monthStr = "0" + dayStr; }//www.ja va2s . c o m if (day < 10) { dayStr = "0" + dayStr; } String nowDate = year + "-" + monthStr + "-" + dayStr; return nowDate; }
From source file:Main.java
/** * parse value to boolean//from w w w. jav a2s . c om */ public static boolean toBoolean(Object value) { if (value instanceof Boolean) { return (Boolean) value; } return value == null ? false : toBoolean(String.valueOf(value)); }
From source file:Main.java
/** * parse value to float//from w w w . jav a2s .com */ public static float toFloat(Object value) { if (value instanceof Number) { return ((Number) value).floatValue(); } return value == null ? 0 : toFloat(String.valueOf(value)); }