时间采用HHMM格式

Sac*_*rma 4 java date

我希望将时间用作HHMM格式,就像军方16小时的下午4点一样.我很好奇:有没有办法通过一些日期格式来获得它?

随意推荐任何第三方库或纯Java API解决方案.

Ren*_*ink 12

使用java.text.SimpleDateFormat

Date date = new Date();
DateFormat format = new SimpleDateFormat("HHmm");
System.out.println(format.format(date));
Run Code Online (Sandbox Code Playgroud)