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(Locale l, String format, Object... args) 

Source Link

Document

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

Usage

From source file:Main.java

public static String toTime(int time) {
    time /= 1000;//w ww.  ja v  a 2  s  . c  o m
    int minute = time / 60;
    int second = time % 60;
    minute %= 60;
    return String.format("%02d:%02d", minute, second);
}

From source file:Main.java

static void checkPositiveOrZero(float number, String name) {
    if (number < 0)
        throw new IllegalArgumentException(String.format("%s %f must be positive", name, number));
}

From source file:Main.java

static void checkPositiveOrZero(float number, String name) {
    if (number < 0)
        throw new IllegalArgumentException(String.format("%s %d must be positive", name, number));
}