这就是我目前所拥有的
Seconds = (60 - timeInMilliSeconds / 1000 % 60);
Minutes = (60 - ((timeInMilliSeconds / 1000) / 60) %60);
我觉得这是正确的。几个小时和几天,应该是这样的-
Hours = ((((timeInMilliSeconds / 1000) / 60) / 60) % 24);
Days = ((((timeInMilliSeconds / 1000) / 60) / 60) / 24) % 24;
然后-
TextView.SetText("Time left:" + Days + ":" + Hours + ":" + Minutes + ":" + Seconds);
但是我的时间和日子都是错误的
发布于 2013-10-30 04:03:12
计算时间的简单方法是使用如下所示的内容
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;
如果你有超过28天的时间,这将会起作用,但如果你有一个负面的时间就不会了。
发布于 2013-10-30 03:32:43
SimpleDateFormat是你的朋友!(我今天才发现的,太棒了。)
SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss", Locale.UK);
Date date = new Date(timeInMilliSeconds);
String result = formatter.format(date);
发布于 2013-10-30 04:22:52
要在android中格式化已用/剩余时间,请使用android.text.format.DateUtils
,特别是getRelativeTimeSpanString
和formatElapsedTime
。
https://stackoverflow.com/questions/19667473
复制相似问题