Use Arguments indexes for a custom time and date format in Java
Description
The following code shows how to use Arguments indexes for a custom time and date format.
Example
//from ww w .j av a2 s .c o m
import java.util.Calendar;
import java.util.Formatter;
public class Main {
public static void main(String args[]) {
Formatter fmt = new Formatter();
Calendar cal = Calendar.getInstance();
fmt.format("Today is day %te of %<tB, %<tY", cal);
System.out.println(fmt);
}
}
The code above generates the following result.