时间为HHMM格式 [英] Time in HHMM format

查看:177
本文介绍了时间为HHMM格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将时间作为HHMM格式使用,例如在军方1600个小时的下午4点使用。我很好奇:是否可以通过某种dateformatter来获得它?

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?

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

Feel free to recommend any third-party library or pure Java API solution.

推荐答案

使用 java.text.SimpleDateFormat

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

这篇关于时间为HHMM格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆