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

public static String padLeft(String s, int n, String c) {
    return String.format("%1$" + n + "s", s).replaceAll(" ", c);
}

From source file:Main.java

public static String padRight(String s, int n, String c) {
    return String.format("%1$-" + n + "s", s).replaceAll(" ", c);
}

From source file:Main.java

private static String getCustomDimensionKey(int paramInt) {
    return String.format("%s%s", new Object[] { "c", String.valueOf(paramInt - 1) });
}

From source file:Main.java

public static String generateHexFromString(String string) {
    return String.format("#ff" + "%06X", (0xFFFFFF & string.hashCode()));
}

From source file:Main.java

public static String getThreadGroupName(String poolName) {
    return String.format("pa-%s-pool", poolName);
}

From source file:Main.java

public static String getFormatTwo(double num) {
    String result = String.format("%.2f", num);
    return result;
}

From source file:Main.java

public static String getNif(int number) {
    String numberStr = String.format("%08d", number);
    return numberStr + getNifLetter(number);
}

From source file:Main.java

public static String truncateBidPrice(String bidPrice) {
    bidPrice = String.format("%.2f", Float.parseFloat(bidPrice));
    return bidPrice;
}

From source file:Main.java

public static String format(String template, Object... values) {
    return String.format(template.replace("{}", "%s"), values);
}

From source file:Main.java

public static String printCustomerID(long id) {
    String idString = String.format("%05d", id);
    String newStringID = "";
    newStringID += idString.substring(0, 2) + "-";
    newStringID += idString.substring(2, 5);
    return newStringID;
}