如何显示毫秒数:小时:分:秒 [英] how to show milliseconds in days:hours:min:seconds
本文介绍了如何显示毫秒数:小时:分:秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我现在所在的
秒=(60 - timeInMilliSeconds / 1000%60);
Minutes =(60 - ((TimeInMilliSeconds / 1000)/ 60)%60);
我觉得是正确的。小时=((((TimeInMilliSeconds / 1000)/ 60)
应该是如下 -
/ 60)%24);
Days =((((TimeInMilliSeconds / 1000)/ 60)/ 60)/ 24)%24;
然后 -
TextView.SetText(Time left:+ Days +:+ Hours +:+ Minutes +:+ Seconds);
但我的时间和日子不正确
解决方案
计算时间的一种简单方法是使用类似于
long seconds = timeInMilliSeconds / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
字符串时间=天+:+小时%24 +:+分钟%60 +:+秒%60;
如果您有超过28天的时间,这将会起作用,但如果您有负面时间,则不会。 / p>
This is what I have at the moment
Seconds = (60 - timeInMilliSeconds / 1000 % 60);
Minutes = (60 - ((timeInMilliSeconds / 1000) / 60) %60);
which I feel is correct. for hours and days should it be like -
Hours = ((((timeInMilliSeconds / 1000) / 60) / 60) % 24);
Days = ((((timeInMilliSeconds / 1000) / 60) / 60) / 24) % 24;
and then-
TextView.SetText("Time left:" + Days + ":" + Hours + ":" + Minutes + ":" + Seconds);
but my hours and days are coming out to be incorrect
解决方案
A simple way to calculate the time is to use something like
long seconds = timeInMilliSeconds / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
String time = days + ":" + hours % 24 + ":" + minutes % 60 + ":" + seconds % 60;
This will work if you have more than 28 days, but not if you have a negative time.
这篇关于如何显示毫秒数:小时:分:秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文