Forums Register Login

Changing Hour to Min

+Pie Number of slices to send: Send
I have a servlet with a method:

/**

* @return <code>double</code> Hours
*/
public double getDriveHours() {
return getAsDouble("DriveTime", 0.0D);
}


I would like to change the time to minutes. I will create a new entry in the db for the minutes, but wondered if the time minutes is also double.

Thanks,
+Pie Number of slices to send: Send
I would expect hour and minutes to have the same type. You can either have fractional hours/minutes in your system or you can't.

As far as converting from hours to minutes, that is easy. What formula could you use?
+Pie Number of slices to send: Send
Time representation is broken into modular parts each represented by an integer hours:minutes:seconds (basic representation)... we know that there are 60 minutes in an hour so to convert hours to minutes we multiply hours * 60 which should give an integer... For time representation I would suggest that you use integer variables for each part.

Example:





From this example you can probably get an idea of a design that suites your application...
+Pie Number of slices to send: Send
 

I would expect hour and minutes to have the same type. You can either have fractional hours/minutes in your system or you can't.



It might make sense to have fractional hours, but not fractional minutes. It's different to want to know that something took 1.5 hours / 90 minutes, than it is to want to know that it took 90.2 minutes.
It depends on what level of precision you need to do the job... if you don't care about seconds, you don't care and that's ok.
1
+Pie Number of slices to send: Send
 

Janeice DelVecchio wrote:It might make sense to have fractional hours, but not fractional minutes. It's different to want to know that something took 1.5 hours / 90 minutes, than it is to want to know that it took 90.2 minutes.


What's wrong with something taking 2.5 minutes?
+Pie Number of slices to send: Send
There's exactly nothing wrong with it, but you might not need that level of precision.

If everything "used" to be reported in hours, minutes might be precise enough. Saying that because fractions of hours were possible means fractions of minutes should be possible is not necessarily a logical assumption.

Maybe somewhere in the app, someone was taking the fraction of the hour and rounding it to the closest minute. Who knows?
please buy my thing and then I'll have more money:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 568 times.
Similar Threads
How to change a 24 hour clock to a 12 hour clock in bluej
Clock problem
how to compute time?
Time Class w/ constructors
Using constructors to add and manage time
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:53:59.