Receive data in seconds, calculate hours, minutes and seconds

I get data containing a specific number.

I need to find how many hours, minutes and seconds it means.

eg:

I get number 248, which means:

00 hours: 04 minutes: 08 seconds

Any ideas will really be applied!

+8
android flex
source share
3 answers

Define hours, minutes, and seconds as follows:

int hours = (int) (time / 3600); int minutes = ((int) (time / 60)) % 60; int seconds = time % 60; 

Alternatively, you can define minutes like this if you know the clock:

 int minutes = (int) ((time - hours * 3600) / 60)); 
+11
source share

You need to reuse milisec. Like 248 * 1000; Then Date d = new date (248 * 1000); And you have a data object. d.getHours (). for example, you can also use SimpleDateFormat. Which can format data using some template and display it on a line. Like yyyy-MM-hh HH: mm

+3
source share

you must first determine how this number is created, for example. why can't he stand behind

00 hours, 02 minutes and 48 seconds

+1
source share

All Articles