如何在Java中获取时间分隔符? [英] How to get the time separator symbol in Java?

查看:32
本文介绍了如何在Java中获取时间分隔符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Java 中获取时间分隔符:"?它是某个地方的常量还是吸气剂?也许有一些等同于 File.separator 的东西?

Is there a way to get the time separator symbol ':' in Java? Is it a constant somewhere or a getter? Maybe there is something equivalent to the File.separator?

我的时间字符串由DateFormat.getTimeInstance(DateFormat.SHORT, locale).format(date);

在这种情况下,当稍后有人想要解析这个字符串时,只使用 ':' 是否安全?

Is it safe to just use ':' in this case when later somebody wants to parse this string?

推荐答案

我认为使用 ':' 是安全的.它被硬编码在 SimpleDateFormat 中.例如:

I think it's safe to use ':'. It is hardcoded in SimpleDateFormat. For example:

if (text.charAt(++pos.index) != ':')

这篇关于如何在Java中获取时间分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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