I am having trouble converting the time 1352364
in seconds to a time stamp format in "Weeks, Days, Hours, Seconds, Minutes". Here is my code so far.
int timeToGrow = 1352364;
int secs = timeToGrow % 60;
int mins = (timeToGrow / 60) % 60;
int hours = (timeToGrow / 60) / 60;
int days = ((timeToGrow / 60) / 60) / 24;
int weeks = (((timeToGrow/60)/60)/24)/7;
System.out.println(weeks + " Weeks "+ days + " Days " + hours + " Hours " + mins + " Minutes " + secs + " Seconds.");
The code should print out 2 Weeks 1 Days 15 Hours 39 Minutes 24 Seconds
, but instead, in prints out 2 Weeks 15 Days 375 Hours 39 Minutes 24 Seconds.
I think I see the problem, however I am not sure how to fix it. Excuse my poor wording, but I think that the hours section includes the time in the days and the weeks section, unlike where the time is seperate, like in minutes and seconds (again, sorry Im not sure how to word it). How can I change the formulas to correctly display the correct timestamp? Thank you very much!