List of usage examples for java.lang String valueOf
public static String valueOf(double d)
From source file:Main.java
public static int[] intToIntArray(long num) { String numStr = String.valueOf(num); int[] array = new int[numStr.length()]; for (int i = 0; i < array.length; i++) { array[i] = (numStr.charAt(i) & 0x0F); }//from ww w. j a va 2s . com return array; }
From source file:controllers.SiteApp.java
/** * @param pageNum page number//from w w w . j a v a 2s .c o m * @return the result */ public static Result issueList(int pageNum) { String state = StringUtils.defaultIfBlank(request().getQueryString("state"), State.OPEN.name()); State currentState = State.valueOf(state.toUpperCase()); Page<Issue> page = Issue.findIssuesByState(ISSUE_COUNT_PER_PAGE, pageNum - 1, currentState); return ok(issueList.render("title.siteSetting", page, currentState)); }
From source file:Main.java
/** * Left pads a number with zeros/* w w w . j a va2 s . c o m*/ * * @param num * The number to pad with zeros * @param zeros * The amount of zeros to pad the number with * @return A String with the number properly padded */ public static String zfill(int num, int zeros) { String n = String.valueOf(num), z_filled = n; for (int i = 0; i < (zeros - n.length()); i++) z_filled = "0" + z_filled; return z_filled; }
From source file:Main.java
/** * Returns 'true' if the pattern matches the src */// w w w . j a v a 2 s . c o m public static String countryMatch(Object src, Object pattern) { if (src.toString().trim().length() == 0) { return "false"; } boolean result = src.toString().toLowerCase().contains(pattern.toString().toLowerCase()); return String.valueOf(result); }
From source file:Main.java
public static String getSize(long size) { if (size < 0) return null; String result = null;/*from ww w.ja va 2s . co m*/ if (size > 1024 * 1024 * 1024) { float f = (float) size / (1024 * 1024 * 1024); String s = String.valueOf(f); if (s.length() - s.indexOf(".") > 2) result = s.substring(0, s.indexOf(".") + 3); else result = s; return result + "GB"; } else if (size > 1024 * 1024) { float f = (float) size / (1024 * 1024); String s = String.valueOf(f); if (s.length() - s.indexOf(".") > 2) result = s.substring(0, s.indexOf(".") + 3); else result = s; return result + "MB"; } else if (size > 1024) { float f = (float) size / 1024; String s = String.valueOf(f); if (s.length() - s.indexOf(".") > 2) result = s.substring(0, s.indexOf(".") + 3); else result = s; return result + "KB"; } else if (size < 1024) { return String.valueOf(size) + "B"; } else return null; }
From source file:Main.java
public static final long[] collection2longArray(Collection<Object> collection) { long[] array = new long[collection.size()]; int index = 0; for (Object value : collection) { try {//from www. j a v a2 s. c o m array[index] = Long.parseLong(String.valueOf(value)); index++; } catch (Exception e) { } } return array; }
From source file:Main.java
public static String getRepeat(int[] results) { String repeatstr = null;/*from w w w .ja va2s. c o m*/ int repeat = 0; for (int i = 0; i < results.length; i++) { if (results[i] == 0) { repeat &= (~(1 << i)); } else { repeat |= (1 << i); } } repeatstr = String.valueOf(repeat); return repeatstr; }
From source file:Main.java
public static final String Object2String(Object obj) { if (null == obj) { return ""; } else if (obj instanceof String) { return (String) obj; } else if (obj instanceof Integer || obj instanceof Double || obj instanceof Float) { return String.valueOf(obj); } else if (obj instanceof String[]) { if (((String[]) obj).length > 0) return String.valueOf(((String[]) obj)[0]); else/*from w w w . ja va 2 s .c o m*/ return ""; } else if (obj instanceof List) { if (((List) obj).size() > 0) return String.valueOf(((List) obj).get(0)); else return ""; } return String.valueOf(obj); }
From source file:Main.java
public static String getNumberRadim(int n) { if (n < 1 || n > 10) { throw new IllegalArgumentException("cannot random " + n + " bit number"); }//from w w w .j ava2s. co m Random ran = new Random(); if (n == 1) { return String.valueOf(ran.nextInt(10)); } int bitField = 0; char[] chs = new char[n]; for (int i = 0; i < n; i++) { while (true) { int k = ran.nextInt(10); if ((bitField & (1 << k)) == 0) { bitField |= 1 << k; chs[i] = (char) (k + '0'); break; } } } return new String(chs); }
From source file:Main.java
public static String getYmdDateDiff(String ymdDate) { String todayYmd = nowDateYymm(); String diffResult = ""; try {//from www . j a va 2 s.c o m diffResult = String.valueOf(Integer.parseInt(todayYmd) - Integer.parseInt(ymdDate)); } catch (Exception e) { e.printStackTrace(); } return diffResult; }