List of usage examples for java.lang String valueOf
public static String valueOf(double d)
From source file:Main.java
public static String generateRank(int numSuperiorRuns) { int position = numSuperiorRuns + 1; String rank = String.valueOf(position); int lastTwoDigits = position % 100; if (lastTwoDigits >= 11 && lastTwoDigits <= 19) { rank += "th"; } else {// w ww .j a v a 2 s . c om switch (position % 10) { case 0: case 4: case 5: case 6: case 7: case 8: case 9: rank += "th"; break; case 1: rank += "st"; break; case 2: rank += "nd"; break; case 3: rank += "rd"; } } return rank; }
From source file:Main.java
/** * * //from www .ja v a 2s.com * @param size * @return */ public synchronized static String convertSize(long size) { String result = String.valueOf(size); if (size < 1024 * 1024) { result = String.valueOf(size / 1024) + " KB"; } else if (size >= 1024 * 1024 && size < 1024 * 1024 * 1024) { result = String.valueOf(size / 1024 / 1024) + " MB"; } else if (size >= 1024 * 1024 * 1024) { result = String.valueOf(size / 1024 / 1024 / 1024) + " GB"; } else { result = result + " B"; } return result; }
From source file:com.moviejukebox.model.enumerations.DirtyFlag.java
/** * Convert a string into an Enum type/*from w ww.ja v a2s . c om*/ * * @param dirtyFlag * @return * @throws IllegalArgumentException If type is not recognised * */ public static DirtyFlag fromString(String dirtyFlag) { if (StringUtils.isNotBlank(dirtyFlag)) { try { return DirtyFlag.valueOf(dirtyFlag.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("DirtyFlag " + dirtyFlag + " does not exist.", ex); } } throw new IllegalArgumentException("DirtyFlag must not be null"); }
From source file:Main.java
public static String retainNumber10(int number) { if (number < 10) { return "0" + number; } else if (number < 100) { return String.valueOf(number); } else {//www.j av a 2 s.c o m return null; } }
From source file:Main.java
public static String insertSpace(String str) { String chr;/*from w w w . j a v a 2 s. com*/ StringBuffer buffer = new StringBuffer(); for (int i = 0; i < str.length(); i++) { chr = String.valueOf(str.charAt(i)); if ((i > 0) && (chr.matches("[A-Z]"))) buffer.append(" "); buffer.append(chr); } return buffer.toString(); }
From source file:Main.java
public static String approximate(int number) { if (number == 0) { return null; }/* www . j a va 2 s . co m*/ if (number < 1000) { return String.valueOf(number); } else if (number < 10000) { float f = number * 1f / 1000; return String.valueOf(Math.round(f * 10) / 10.0) + "k"; } else { float f = number * 1f / 10000; return String.valueOf(Math.round(f * 10) / 10.0) + "w"; } }
From source file:Main.java
public static String getScores(int home_goals, int awaygoals) { if (home_goals < 0 || awaygoals < 0) { return " - "; } else {//from w ww . ja v a 2 s . co m return String.valueOf(home_goals) + " - " + String.valueOf(awaygoals); } }
From source file:Main.java
public static String putUserUpdateUrl(long userId) { return KILLERBONE_FULL_URL + "user/" + String.valueOf(userId); }
From source file:Main.java
public static String toDate(Long aLong) { String beginDate = String.valueOf(aLong); @SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(new Date(Long.parseLong(beginDate))); }
From source file:Main.java
public static String getLastModifiedTime(String filePath) { File file = new File(filePath); if (file.exists()) { return String.valueOf(file.lastModified()); }// w w w . jav a 2s . co m return null; }