Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #11356
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How can I use Operand (+ , - ) with Time |
| Date | 2012-01-15 10:31 -0800 |
| Organization | albasani.net |
| Message-ID | <jev61p$eh7$1@news.albasani.net> (permalink) |
| References | <34afdd1f-4549-48a9-878c-8678993e97ed@t30g2000vbx.googlegroups.com> <operator-overloading-20120115135044@ram.dialup.fu-berlin.de> |
On 01/15/2012 04:51 AM, Stefan Ram wrote: > sahm<sahm007@gmail.com> writes: >> But how can I use operand (+, -) with Time > > You need to find or implement a compiler or interpreter for > a language that supports operator overloading (Java does not). > > Or, convert all times into values of the primitive Java data > type »double« (such as a count of seconds) and then used »+« > with those double values. That tends to cause trouble. It's better to use 'java.util.Calendar' and its friends prior to Java 7, and the new time types for 7+. The application apparently tracks working hours. How much overtime does someone in New York get who works eight hours nornmally but works from midnight to eight a.m. on November 4, 2012? Naive calculations based on double or int values for number of seconds in an hour will give you the wrong answer. To get the right answer across all possible dates and locales (e.g., March 25, 2012, in London, UK), you will need all kinds of complicated calculation. Heck, just to get the right number of days in February (say, year 2100) requires some dancing. Tou will note that the OP's example committed this error. Why in the heck would you recommend 'double' as a time, date or interval type? It's very inappropriate. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How can I use Operand (+ , - ) with Time sahm <sahm007@gmail.com> - 2012-01-14 23:44 -0800
Re: How can I use Operand (+ , - ) with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 08:32 -0500
Re: How can I use Operand (+ , - ) with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 08:52 -0500
Re: How can I use Operand (+ , - ) with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 10:19 -0500
Re: How can I use Operand (+ , - ) with Time sahm <sahm007@gmail.com> - 2012-01-15 07:55 -0800
Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 10:50 -0800
Re: How can I use Operand (+ , - ) with Time Roedy Green <see_website@mindprod.com.invalid> - 2012-01-15 08:35 -0800
Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 10:31 -0800
Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 10:51 -0800
Re: How can I use Operand (+ , - ) with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 14:45 -0500
Re: How can I use Operand (+ , - ) with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 15:53 -0500
Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 15:36 -0800
Re: How can I use Operand (+ , - ) with Time glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-15 20:07 +0000
Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 15:39 -0800
csiph-web