如何从DateFormat中删除SECONDS字段 [英] How to remove the SECONDS field from a DateFormat

查看:53
本文介绍了如何从DateFormat中删除SECONDS字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使用区域设置的默认格式打印不带秒的时间. 所以我用getTimeInstance()getTimeInstance(int style)获得了格式化程序.但是,即使我使用SHORT样式,它也会同时包含秒的一部分.

I want to print a time without seconds in the default format for the locale. So I get the formatter with getTimeInstance() or getTimeInstance(int style). But even when I use a SHORT style it will contain the seconds part of the time as well.

有什么办法(除了创建自己的格式,该格式不会成为语言环境的默认设置并手动维护),我可以获取默认设置并分割秒数吗?

Is there any way (apart from creating my own format, which then would not be the locale default and manually maintained) I can grab the default and split off the seconds ?

谢谢

罗马

推荐答案

DateFormat.getTimeInstance( DateFormat.SHORT )在这里工作得很好:从 20:00:00 20:00 以及从 8:00:00 PM 到8:00 PM .

DateFormat.getTimeInstance(DateFormat.SHORT) works perfectly fine here: from 20:00:00 to 20:00 and from 8:00:00 PM to 8:00 PM.

这篇关于如何从DateFormat中删除SECONDS字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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