I'm getting a data which contains a certain number.
我得到的数据包含一个特定的数字。
I need to find how many hours, minutes and seconds it stands for.
我需要知道它代表了多少小时,分,秒。
for example:
例如:
I'm getting the number 248 which means:
我得到的数字是248,意思是:
00 hours : 04 minutes : 08 seconds
00小时:04分钟:08秒
Any ideas would be really apprieciated!
任何想法都将被真正地决定!
3 个解决方案
#1
12
Determine hours, minutes and seconds like this:
像这样确定时间、分钟和秒:
int hours = (int) (time / 3600);
int minutes = ((int) (time / 60)) % 60;
int seconds = time % 60;
Alternatively, you can determine minutes like this once you know the hours:
或者,一旦你知道了时间,你就可以确定像这样的分钟:
int minutes = (int) ((time - hours * 3600) / 60));
#2
3
You need to multiple it to milisec. Like 248*1000; Then Date d = new Date(248*1000); And youll have data object. d.getHours(). for example also you can use SimpleDateFormat. Which can format data with some pattern and output it to string Like yyyy-MM-hh HH:mm
你需要把它乘以千分之一。像248 * 1000;则日期d =新日期(248*1000);你会有数据对象。d.getHours()。例如,您还可以使用SimpleDateFormat。它可以用某种模式格式化数据,并将其输出到像yyyy-MM-hh - HH:mm这样的字符串中。
#3
1
you have to define first, how this number is build up, e.g. why it can not stand for
你必须首先定义,这个数字是如何建立的,例如为什么它不能代表。
00 hours, 02 minutes and 48 sseconds
00小时02分48秒
#1
12
Determine hours, minutes and seconds like this:
像这样确定时间、分钟和秒:
int hours = (int) (time / 3600);
int minutes = ((int) (time / 60)) % 60;
int seconds = time % 60;
Alternatively, you can determine minutes like this once you know the hours:
或者,一旦你知道了时间,你就可以确定像这样的分钟:
int minutes = (int) ((time - hours * 3600) / 60));
#2
3
You need to multiple it to milisec. Like 248*1000; Then Date d = new Date(248*1000); And youll have data object. d.getHours(). for example also you can use SimpleDateFormat. Which can format data with some pattern and output it to string Like yyyy-MM-hh HH:mm
你需要把它乘以千分之一。像248 * 1000;则日期d =新日期(248*1000);你会有数据对象。d.getHours()。例如,您还可以使用SimpleDateFormat。它可以用某种模式格式化数据,并将其输出到像yyyy-MM-hh - HH:mm这样的字符串中。
#3
1
you have to define first, how this number is build up, e.g. why it can not stand for
你必须首先定义,这个数字是如何建立的,例如为什么它不能代表。
00 hours, 02 minutes and 48 sseconds
00小时02分48秒