Time in HHMM format

date, java

Solution

Use the java.text.SimpleDateFormat

Date date = new Date();
DateFormat format = new SimpleDateFormat("HHmm");
System.out.println(format.format(date));

Problem

I want to use time as a HHMM format, like in the military's 1600 hrs for 4 PM. I was curious: Is there a way of getting it so by some dateformatter? Feel free to recommend any third-party library or pure Java API solution.

Original source