Results 1 to 3 of 3
hi there i have a java question that i need help with.
i am trying to convert a double to time. so for example my result comes out like 3.18 ...
- 05-14-2009 #1Linux Newbie
- Join Date
- Dec 2006
- Posts
- 119
[SOLVED] Convert Double to Time
hi there i have a java question that i need help with.
i am trying to convert a double to time. so for example my result comes out like 3.18 hours. so how i could convert that to time? i wanted to be formatted like HH MM SS.
thanks for your help in advance.
- 05-14-2009 #2Linux Newbie
- Join Date
- Dec 2006
- Posts
- 119
so i was able to figure it out by myself
......... but i am getting the wrong output.
the problem that i am having is with one variable that is screwing everything up.
here is my problem...
and when i check "walking_ts" i am getting 10,800 seconds instead of 11,448 seconds.Code:double distance = 10.0; double walking = (distance/3.14); int walking_ts = (int)walking*3600; int walking_h = (int)(walking_ts/3600); int walking_m = (int)((walking_ts%3600)/60); int walking_s = (int)(walking_ts%60.0);
any thoughts why i am getting the wrong output on my variable?
- 05-15-2009 #3Linux Newbie
- Join Date
- Dec 2006
- Posts
- 119
i guess i solve my own problem
.
all i had to do was changeto...Code:int walking_ts = (int)walking*3600;
and yes all i did was to add parentesis to it :S, how weird. for some odd reason the variables were passing somewhere.Code:int walking_ts = (int)(walking*3600);


