Example usage for java.lang String format

List of usage examples for java.lang String format

Introduction

In this page you can find the example usage for java.lang String format.

Prototype

public static String format(String format, Object... args) 

Source Link

Document

Returns a formatted string using the specified format string and arguments.

Usage

From source file:Main.java

private static String indexKey(String key, int index) {
    return key + ":" + String.format("%10d", index);
}

From source file:Main.java

public static String doFormat(String sourceStr, String[] strs) {
    return String.format(sourceStr, strs);
}

From source file:Main.java

public static String paddLeft(String src, int length, char padding) {
    return String.format("%" + length + "s", src).replace(' ', padding);
}

From source file:Main.java

public static String getLotteryNumberString(int num, int digitLength) {
    return String.format("%0" + digitLength + "d", num);
}

From source file:Main.java

public static String DoubleFormat(Double val) {
    try {//  w w  w .  jav a 2  s . co  m
        return String.format("%.2f", val);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "0.00";
}

From source file:Main.java

static String where(String columnName) {
    return String.format("%s=?", columnName);
}

From source file:Main.java

public static String keepOneAfterDot(double value) {
    String back = "";
    back = String.format("%.2f", value);
    return back;/* ww  w  .j  a va  2 s  .  c o  m*/
}

From source file:Main.java

public static String keepTwoAfterDot(double value) {
    String back = "";
    back = String.format("%.2f", value);
    return back;/* www .j  a va 2  s. c o m*/
}

From source file:Main.java

public static String formatByteToKB(int size) {
    float kb = size / 1024f;
    return String.format("%.2f", kb);
}

From source file:Main.java

public static String formatRGBColor(int color) {
    return "colorDec=" + color + ", colorHex=" + String.format("#FF%06x", color);
}