We would like to know how to add colon to 24 hour time.
import java.text.SimpleDateFormat; import java.util.Date; //from w w w. j av a2 s. c o m public class Main { public static void main(String[] args) { Date d = new Date(); SimpleDateFormat sd = new SimpleDateFormat("MMMM dd, YYYY"); SimpleDateFormat sd1 = new SimpleDateFormat("HH:mm"); String s = sd.format(d); String s1 = sd1.format(d); System.out.println(s + " " + s1); } }
The code above generates the following result.