java.util.Date issues
Dear all,
I have to handle a period with "fromDate" and "toDate".
The idea is to provide default values for these two dates.
For "fromDate", I can use "new Date(0) ".
For "toDate", I can use "new Date(Long.MAX_VALUE )".
However, I don't think that the above ideas are the best way of handle the issue.
Do you have a better idea?
Cheers,
Pengyou
[401 byte] By [
pengyoua] at [2007-10-2 2:06:01]

Why do you need this? There is no logical reason to have such min/max dates (or is it just a technical way to have some boundaries?). If these values are "default", and you have the default case, then you have 2 invalid dates (or at least 2 dates that you probably don't want to). First think of the real min and max values your application should process and then hard wire them instead of 0 and Long.MAX_VALUE.
if you're only after some reasonable default values, why not set fromDate to new Date() and toDate to fromDate plus 24 hours, or plus a week, or plus a fortnight.. depends on the application
well then depends on the context, no?
if this is for a reservation system of some kind, for example, it wouldn't be unreasonable to assume that fromDate would be for instance the day after tomorrow and toDate a week later?
you could also consider issuing an error message if the dates have not been filled, it would be on the benefit of the user.