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 getPlotSize(int size, int num) { double data = size / (100.00); String result = String.format("%." + num + "f", data); return result; }
From source file:Main.java
public static String priceFormat(double price) { String string = String.format("%.02f", price); return string; }
From source file:Main.java
public static String getHexStringFromInt(int color) { return "#" + String.format("%06X", 0xFFFFFF & color); }
From source file:Main.java
public static String formatAcademyNo(int academyNo) { return String.format("%0" + academyNoLength + "d", academyNo); }
From source file:Main.java
public static String numberToString(int value) { return String.format(NUMBER_FORMAT, value); }
From source file:Main.java
public static String GetFileSizeStr(long size) { if (size > 1000 * 1000 * 1000) { return String.format("%.2f GB", size / (double) (1000 * 1000 * 1000)); } else if (size > 1000 * 1000) { return String.format("%.2f MB", size / (double) (1000 * 1000)); } else if (size > 1000) { return String.format("%.2f KB", size / (double) (1000)); } else {/* w w w. j a v a2 s . co m*/ return String.format("%d B", size); } }
From source file:Main.java
static String bin2hex(byte[] data) { return String.format("%0" + (data.length * 2) + "X", new BigInteger(1, data)); }
From source file:Main.java
public static String format(Context context, int stringId, Object... args) { return String.format(context.getString(stringId), args); }
From source file:Main.java
public static void checkNotNull(Object o, String name) { if (o == null) throw new IllegalArgumentException(String.format("%s must be not null", name)); }
From source file:Main.java
public static String getFormattedColorString(int color, boolean showAlpha) { if (showAlpha) { return String.format("#%08X", color); } else {/*from w w w .j a va 2 s . com*/ return String.format("#%06X", 0xFFFFFF & color); } }