0
Converting time to normal time
Hi guys, I have to write a method to convert a time with 10hours 100minutes and 100seconds for a day to our standard clock time. The input is Time(5, 55, 56) Output should be (13, 20, 0) I have tried: Time toTime{ sec = 56*60/100; min = 55*60/100; hour = 5*24/10; return Time(hour,min,sec); } My output is (12,33,33) Thanks for your help Cheers
2 Respuestas
+ 2
1day in that time is equivalent to 100000ss.
1day in our standard time is equivalent to 86400s.
find the ratio so later we can convert seconds from on time to the other.
Then proceed to convert the given time, in this case 5hh55mm56ss to ss, which gives 55556ss.
Use the ratio to convert ss to s. Youll get 48000.384s, round it up to 48000s and from here you convert it to h m s.
I've never used java, so I cant give u a code. :/
+ 1
Reduce the given metric time to the unit that is the same in both metric time and standard time, which is seconds. That is hrs*10*100 + mins*100 + secs. Then reconstruct standard time in seconds, minutes and hours from that total number of seconds. That is tot%60 secs, (tot/60)%60 mins, tot/3600 hrs.