Android 整数到字符串时间格式
我有从资源中提取的整数。它们是时间,但由于我必须将它们作为整数存储在资源文件中,所以我将 9 分 8 秒存储为 0908。我想在屏幕上将其显示为 09:08,但似乎不知道该怎么做它。
我确信有一种简单的方法,但我似乎找不到。
I have integers that I pull from resources. They are times but since I have to store them as an integer in the resource file I store 9 minutes and 8 seconds as 0908. I want to display this as 09:08 on the screen but can't seem to figure out how to do it.
I'm sure there is an easy way but I can't seem to find one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个例子:
Here is an example:
您可以使用一些数学方法将其拆分(分钟除以 100,秒除以 100)
,也可以使用 SimpleDateFormat 来解析和/或显示。 http://download.oracle.com/javase/7 /docs/api/java/text/SimpleDateFormat.html
You could either split it using some math ( divide by 100 for minutes and modulo 100 for seconds)
or you could use SimpleDateFormat to parse and/or display. http://download.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html