Reputation: 5899
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.
Upvotes: 2
Views: 9529
Reputation: 1736
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
Upvotes: 0
Reputation: 74780
Here is an example:
String result = String.format("%02d:%02d", intTime / 100, intTime % 100);
Upvotes: 6