List of usage examples for java.lang String valueOf
public static String valueOf(double d)
From source file:Main.java
public static String[] intToStringArray(int[] array) { int arrayLength = array.length; String[] stringArray = new String[arrayLength]; for (int i = 0; i < arrayLength; i++) { stringArray[i] = String.valueOf(array[i]); }/* www.j a v a 2 s . c o m*/ return stringArray; }
From source file:Main.java
protected static String generateNonce() { long l = c.nextLong(); int i = (int) (System.currentTimeMillis() / 60000L); return (new StringBuilder(String.valueOf(l))).append(":").append(i).toString(); }
From source file:Main.java
public static String longSizeToStr(long contentLength) { float length = contentLength; String strLen;//from w w w. j a v a 2 s . c om if (length >= 1024 * 1024 * 1024) { length /= 1024 * 1024 * 1024; String s = String.valueOf(length); strLen = s.substring(0, s.length() > 4 ? 4 : s.length()) + "GB"; while (strLen.length() < 6) { strLen = strLen.replace("GB", "0GB"); } } else if (length >= 1024 * 1024) { length /= 1024 * 1024; String s = String.valueOf(length); strLen = s.substring(0, s.length() > 4 ? 4 : s.length()) + "MB"; while (strLen.length() < 6) { strLen = strLen.replace("MB", "0MB"); } } else if (length >= 1024) { length /= 1024; String s = String.valueOf(length); strLen = s.substring(0, s.length() > 4 ? 4 : s.length()) + "KB"; while (strLen.length() < 6) { strLen = strLen.replace("KB", "0KB"); } } else { strLen = (int) (length) + "B"; } for (int i = 0; i < strLen.length(); i++) { if (strLen.charAt(i) == '.' && i == strLen.length() - 3) { strLen = strLen.substring(0, i) + strLen.substring(i + 1); break; } } return strLen; }
From source file:Main.java
/** * Composes the xml for an friendship location update */// w ww .ja v a 2 s. c o m public static String composeFriendshipLocationUpdateXml(double latitude, double longitude) { return String.format("<location><latitude>%s</latitude><longitude>%s</longitude></location>", String.valueOf(latitude), String.valueOf(longitude)); }
From source file:Main.java
public static String getRemainingTimeInDaysAndHours(long timeInMillis) { long seconds = timeInMillis / 1000; long minutes = seconds / 60; long hours = minutes / 60; long days = hours / 24; long actualHours = hours - days * 24; return String.valueOf(days + "Days - " + actualHours + "Hours"); }
From source file:Main.java
public static String[] build(Object... values) { String[] arr = new String[values.length]; for (int i = 0; i < values.length; i++) { if (values[i] instanceof Boolean) { boolean value = (Boolean) values[i]; arr[i] = String.valueOf(value ? 1 : 0); } else {//from ww w . ja v a 2 s . c om arr[i] = String.valueOf(values[i]); } } return arr; }
From source file:Main.java
public static java.util.List<String> getLabelsFromInt(Cursor c) { c.moveToFirst();/*w ww. j a v a2s .c o m*/ ArrayList<String> res = new ArrayList<>(); for (int i = 0; i < c.getCount(); i++) { res.add(i, String.valueOf(c.getInt(0))); c.moveToNext(); } return res; }
From source file:Main.java
public static List<String> getLettersFromMotId(String motId) { List<String> res = new ArrayList<String>(); for (int i = 0; i < motId.length(); i = i + 2) { int nbLetters = Integer.valueOf(String.valueOf(motId.charAt(i))); for (int k = 0; k < nbLetters; k++) { res.add(String.valueOf(motId.charAt(i + 1))); }/*from w ww.j a v a 2s. c o m*/ } return res; }
From source file:Main.java
protected static String getURL(String ipaddr, String path, String params) { StringBuffer sb = new StringBuffer(); sb.append("http://"); sb.append(ipaddr);/* w w w . j a v a 2 s . co m*/ sb.append(":"); sb.append(String.valueOf(WebServerPort)); sb.append(path); if (params != null) { sb.append("?"); sb.append(params); } return sb.toString(); }
From source file:Main.java
public static boolean isChineseChar(String value) { try {/*from w w w .j ava 2 s .c o m*/ if (value == null) return false; char[] chars = value.toCharArray(); for (int i = 0; i < chars.length; i++) { String target = String.valueOf(chars[i]); byte[] b = target.getBytes(); if (b.length == 2) { } else { return false; } } return true; } catch (Exception e) { return false; } }