Format hour in KK (00-11) format like 00, 01,..11 in Java
Description
The following code shows how to format hour in KK (00-11) format like 00, 01,..11.
Example
// w w w. ja va2 s .c o m
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("KK");
System.out.println("hour in KK format : " + sdf.format(date));
}
}
The code above generates the following result.