P
Paul Lutus
Erwin Moller wrote:
/ ...
Most likely they hired the least expensive programmers they could find, with
the predictable result that the code reflects the qualifications of those
individuals. Remember, Sun is a corporation, not a monastery.
One could make the argument that GregorianCalendar is 80% of what Date
should have been originally -- all that is needed is to add what remains of
Date to it.
And as you have seen, that is trivial. Just get the difference between two
dates in milliseconds, then divide by an appropriate constant depending on
the desired result.
But these are all trivially acquired by dividing the original millisecond
result by an appropriate constant. It won't work for months or years, for
obvious reasons.
Also, in Java, you could extend GregorianCalendar to provide these extra
methods in a matter of minutes (no pun intended).
Calendar difference results don't need to make those kinds of adjustments
(assuming both values are from the same source).
Yep. "They" are called GregorianCalendar, plus a small bit of effort on your
part.
But not correctly. They had the same problems that plagued Java. And now VB
has been scheduled for abandonment by Microsoft, a lame effort to get
people to switch all their code to C# or something else.
/ ...
I have 1 question left:
Why didn't Sun just release a better version of Date?
Most likely they hired the least expensive programmers they could find, with
the predictable result that the code reflects the qualifications of those
individuals. Remember, Sun is a corporation, not a monastery.
(the GoodDate class
or something)
Or should I consider GregorianCalendar as the improved version?
One could make the argument that GregorianCalendar is 80% of what Date
should have been originally -- all that is needed is to add what remains of
Date to it.
I ask this because I find myself doing basic stuff like getting intervals
(or elapsed time) based on 2 dates.
And as you have seen, that is trivial. Just get the difference between two
dates in milliseconds, then divide by an appropriate constant depending on
the desired result.
(A bit like public int daysBetween (Day day) in
http://geosoft.no/software/day/Day.java.html (posted by Jacob) )
What I miss in GregorianCalendar is things like:
(phantasy-code)
GregorianCalendar Cal1 = new GregorianCalendar(2004,7,2);
GregorianCalendar Cal2 = new GregorianCalendar(2005,8,28);
// express the difference in seconds.
double dDiffInSecs = GregorianCalendar.getDiff(Cal1,Cal2,CALENDAR_SEC);
// express the difference in days.
double dDiffInDays = GregorianCalendar.getDiff(Cal1,Cal2,CALENDAR_DAY);
But these are all trivially acquired by dividing the original millisecond
result by an appropriate constant. It won't work for months or years, for
obvious reasons.
Also, in Java, you could extend GregorianCalendar to provide these extra
methods in a matter of minutes (no pun intended).
Ideally the getDiff method would correct for any leapseconds,
timesettings, etc.
Calendar difference results don't need to make those kinds of adjustments
(assuming both values are from the same source).
Maybe similar are classes around somewhere and I just missed them
completely.
Yep. "They" are called GregorianCalendar, plus a small bit of effort on your
part.
It has been many years now since I coded VBscript, but if memory serves me
well those VB guys had functions that did this.
But not correctly. They had the same problems that plagued Java. And now VB
has been scheduled for abandonment by Microsoft, a lame effort to get
people to switch all their code to C# or something else.