Re: Help, baffled by date handling - is everything deprecated?
Re: Help, baffled by date handling - is everything deprecated?
- Subject: Re: Help, baffled by date handling - is everything deprecated?
- From: Marek Wawrzyczny <email@hidden>
- Date: Fri, 13 Jun 2003 12:55:53 +1000
On Friday, Jun 13, 2003, at 12:27 Australia/Sydney, Denis Stanton wrote:
Can anyone point me to the correct function for what I hope are simple
date calculations. I've spent a lot of time reading through the
methods but nearly everything says it's deprecated and refers me to
something else. The API seems to be a bit messy.
I'm using WebObjects 5.2 with Java 1.3.1 of course.
You'll notice that NSTimestamp is a subclass of java.util.Date. Check
out Sun's API docs on java.util.Date and you will find
java.util.Calendar and/or java.util.GregorianCalendar useful too. The
last two have methods that will help you implement most date operations.
It seems that all date objects have been deprecated in favour of
NSTimestamp. That's OK except that the timestamps define a point
down to the millisecond level and I only want to work in days. If I
use a method like 'after', as in "if ( startdate.after(someDate)"
the comparison will figure out the milliseconds so two events on the
same date will not have the same timestamp.
So the question here is, how do I tell NSTimestamp to ignore the units
smaller than 1 day - or should I be using a different object?
Construct new NSTimestamp or Date objects where the time part of the
timestamp is set to zero, then do the comparisons.
The second problem is with intervals. I can't find a method to
calculate the number of days between two dates.
Again, check Sun's API on java.util.Calendar and/or
java.util.GregorianCalendar they have methods that will help you
achieve this.
I apologize for asking such basic questions. I really expected this
to be simple but I just can't find my way through the deprecations and
"see alsos" in the documentation.
No worries. I think that evryone agrees that timestamp operations in
Java are definitely finicky.
Marek Wawrzyczny
software engineer
-------------------------->
ish group pty ltd
7 Darghan St Glebe 2037 Australia
phone +61 2 9660 1400 fax +61 2 9660 7400
http www.ish.com.au | email email@hidden
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.