Format time to just hour and minute in Java
Description
The following code shows how to format time to just hour and minute.
Example
/*from ww w. j av a 2s . 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 = new Formatter();
fmt.format("%tl:%tM", cal, cal);
System.out.println(fmt);
}
}
The code above generates the following result.