List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
public static String getCurrentMonthFirstDay(long time) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM", Locale.CHINA); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(dateFormat.format(time)); stringBuilder.append("-"); stringBuilder.append(1);/*from w w w . ja v a 2 s . c om*/ return stringBuilder.toString(); }
From source file:Main.java
private static void addUnits(StringBuilder stringBuilder, int value, String units) { stringBuilder.append(" "); if (value == 1) stringBuilder.append(units + " "); else/*w w w . ja va 2 s .c o m*/ stringBuilder.append(units + "s "); }
From source file:Main.java
private static StringBuilder appendIntToStringBuilder(StringBuilder sb, int value) { if (value < 10) { sb.append('0'); }// w ww . j ava2 s. c om return sb.append(value); }
From source file:Main.java
private static int generateRequestCode(int resId, int widgetId) { StringBuilder sb = new StringBuilder(); sb.append(resId); sb.append(" "); sb.append(widgetId);// w w w.jav a2s. c o m // Only needed if we have more problems with uniqueness. //sb.append(System.currentTimeMillis()); return sb.toString().hashCode(); }
From source file:Main.java
public static String getVCard(String dcIdentityStr) { if (dcIdentityStr == null || "".equals(dcIdentityStr.trim())) return (null); // If the identity is already a vcard, return it as is. if (dcIdentityStr.trim().startsWith("BEGIN:VCARD")) return (dcIdentityStr.trim()); // Otherwise, create a simple vcard with only the FN field. StringBuilder str = new StringBuilder(); str.append("BEGIN:VCARD\n"); str.append("VERSION:3.0\n"); str.append("FN:" + dcIdentityStr); str.append("END:VCARD"); return (str.toString()); }
From source file:Main.java
public static byte[] hexStringToByteArray(String encoded) { if ((encoded.length() % 2) != 0) throw new IllegalArgumentException("Input string must contain an even number of characters"); final byte result[] = new byte[encoded.length() / 2]; final char enc[] = encoded.toCharArray(); for (int i = 0; i < enc.length; i += 2) { StringBuilder curr = new StringBuilder(2); curr.append(enc[i]).append(enc[i + 1]); result[i / 2] = (byte) Integer.parseInt(curr.toString(), 16); }/*from www .ja v a 2 s. c o m*/ return result; }
From source file:Main.java
public static String int2String(int i, int digits, boolean leadingZero) { StringBuilder s = new StringBuilder(digits); s.append(Integer.toString(i)); while (s.length() < digits) { s.insert(0, (leadingZero ? "0" : " ")); }/* ww w . java 2 s . c o m*/ return s.toString(); }
From source file:Main.java
/** * Creates a Track name string from the name. * /*from ww w .j a v a2 s. co m*/ * @param name the name of the track. * @return the gpx string. */ public static String getTrackNameString(String name) { StringBuilder sb = new StringBuilder(); sb.append("<name>" + name + "</name>").append("\n"); return sb.toString(); }
From source file:Main.java
public static String createXml(SortedMap<String, String> sm, String sign) { StringBuilder sb = new StringBuilder(); sb.append("<xml>"); Set<Map.Entry<String, String>> set = sm.entrySet(); for (Iterator<Map.Entry<String, String>> it = set.iterator(); it.hasNext();) { Map.Entry<String, String> entry = it.next(); sb.append("<").append(entry.getKey()).append(">"); sb.append(entry.getValue());/*from www . java2s . com*/ sb.append("</").append(entry.getKey()).append(">"); } sb.append("<sign>").append(sign).append("</sign>"); sb.append("</xml>"); return sb.toString(); }
From source file:Main.java
public static String createXML(SortedMap<String, Object> parameters) { StringBuilder buffer = new StringBuilder(); buffer.append("<xml>"); for (Entry<String, Object> entry : parameters.entrySet()) { String k = (String) entry.getKey(); String v = String.valueOf(entry.getValue()); if (!"null".equals(v) && !"".equals(v)) { buffer.append("<" + k + ">" + v + "</" + k + ">" + "\r\n"); }/* www . j a v a2 s . c o m*/ } buffer.append("</xml>"); return buffer.toString(); }