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 keepOneAfterDotBylong(long value) {
    String back = "";
    back = String.format("%.1f", value);
    return back;/*from  w w w  .  j a va 2  s  .  com*/
}

From source file:Main.java

public static String padLeft(String s, int n) {
    if (s.length() == 1)
        return String.format("%0s" + n + "s", s);
    else//from   w  w w .j a  va  2  s.  c  om
        return "";
}

From source file:Main.java

public static String printDateCalendar(Calendar calendar) {
    return String.format("%1$td-%1$tm-%1$tY", calendar);
}

From source file:Main.java

public static String printTimeCalendar(Calendar calendar) {
    return String.format(" %1$tI:%1$tM %1$Tp", calendar);
}

From source file:Main.java

public static String printFullCalendar(Calendar calendar) {
    return String.format("%1$ta %1$td %1$tb %1$tY at %1$tI:%1$tM %1$Tp", calendar);
}

From source file:Main.java

public static String colorString(int color) {
    return String.format("#%06X", (0xFFFFFF & color));
}

From source file:Main.java

public static String formatString(String format, Object... args) {
    try {/* w w  w  .  jav a 2s .c o m*/
        return String.format(format, args);
    } catch (Exception e) {
    }
    return "";
}

From source file:Main.java

License:asdf

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

From source file:Main.java

public static String getHexColor(final int color) {
    return String.format("#%06X", (0xFFFFFF & color));
}

From source file:Main.java

static String getColorValues(int color) {

    return String.format("%06x", (0xFFFFFF & color));

}