开发者

Android Integer to String time format

I have integers that I pull from resources. They are times but since I have to store them as an integer in the res开发者_如何学编程ource 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.


Here is an example:

String result = String.format("%02d:%02d", intTime / 100, intTime % 100);


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜