List of usage examples for java.lang String format
public static String format(String format, Object... args)
From source file:Main.java
public static String decimalFormat(float f) { double d = (double) f; if (d == (long) d) return String.format("%d", (long) d); else//from www . ja v a 2s . c om return String.format("%s", d); }
From source file:Main.java
public static String getZeroFormat(int data) { String result = ""; try {// w w w . j ava 2 s . c o m result = String.format("%02d", data); } catch (Exception e) { e.printStackTrace(); result = ""; } return result; }
From source file:Main.java
public static String getForMartSize(int size, int num) { double data = size / (1024 * 1024.00); String result = String.format("%." + num + "f", data); result = result + "M"; return result; }
From source file:Main.java
public static void checkPositive(int number, String name) { if (number <= 0) throw new IllegalArgumentException(String.format("%s must not be null", name)); }
From source file:Main.java
public static String getFloatString2Decimal(float aFloatValue) { String ret = String.format("%.2f", aFloatValue); return ret.replace(',', '.'); }
From source file:Main.java
public static String amount2String(String amount) { String temp = amount.replace(".", "").replace(",", ""); return String.format("%012d", Long.parseLong(temp)); }
From source file:Main.java
public static String formatBtiNum(int bignum) { try {/*www . ja v a2s.c o m*/ return String.format("%,d", bignum); } catch (Throwable e) { } return String.valueOf(bignum); }
From source file:Main.java
public static String getStringFormat(Context context, int format, Object... str) { return String.format(context.getText(format).toString(), str); }
From source file:Main.java
/** * /* w w w . ja v a2s. c o m*/ * @param input * @return */ public static String degreesToFour(int input) { String four = String.format("%04d", input); return four; }
From source file:Main.java
public static String formatNoaaForCalendar(Calendar c) { return "" + c.get(Calendar.YEAR) + "-" + String.format("%02d", (c.get(Calendar.MONTH) + 1)) + "-" + String.format("%02d", c.get(Calendar.DATE)); }