如何在Android中将数字转换为小时和分钟 [英] How to convert number to hour and minute in android
本文介绍了如何在Android中将数字转换为小时和分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我应该显示小时和分钟,并通过以下示例从服务器获取此数字:
Json :
In my application i should show hour and minute and i get this numbers from server with this sample :
Json :
{
data:{
time:84561
}
}
我应该从时间获取此数字并显示此信息格式
i should get this number from time and show it with this format
**hh : mm : ss**
我可以获得时间,但我无法将其转换为 ** hh:mm:ss **
。
I can get number of time, but i can't convert this to **hh : mm : ss**
.
我怎么办?
推荐答案
long timeSec= 84561;// Json output
int hours = (int) timeSec/ 3600;
int temp = (int) timeSec- hours * 3600;
int mins = temp / 60;
temp = temp - mins * 60;
int secs = temp;
String requiredFormat = hours+ ": "+mins+": "+secs;//hh:mm:ss formatted string
这篇关于如何在Android中将数字转换为小时和分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文