Sure, it all boils down to your business requirements. Based on your original post, it really wasn't clear what constraints you were operating within. All else being equal, I'd opt not to create Calendar objects, but if you have to, you have to...

Lamine Ba wrote:
Hi Khris,
That's what I was doing before.  The problem with this strategy is that
I also have to handle months in the calendar that are more or less than
30 days.  Moreover, there is no simple way to set the time to 0 and do
Day operations only.

T Lamine Ba
Software Intelligence for Real Estate Professionals.

-----Original Message-----
From: Kris Schneider [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 15, 2005 4:46 PM
To: Tag Libraries Users List
Subject: Re: [OT] Java Tip

Or, create yourself a utility class:

public class TimeConstants {
     public static final long SECOND_MS = 1000;
     public static final long MINUTE_MS = 60 * SECOND_MS;
     public static final long HOUR_MS = 60 * MINUTE_MS;
     public static final long DAY_MS = 24 * HOUR_MS;
     // add another here for two days if it's used often enough
}

Then:

return (timestamp.getTime() >= (System.currentTimeMillis() + (2 * TimeConstants.DAY_MS)));

Lamine Ba wrote:

I thought I should use Calendar.  However, I was not sure how to
manipulate the library.  Thanks for the tips Rahul and John.  They

will

save me a lot of time.

T Lamine Ba
Software Intelligence for Real Estate Professionals.



-----Original Message-----
From: John Byrd [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 15, 2005 3:52 PM
To: Tag Libraries Users List
Subject: Re: Java Tip

Calendar cal = Calendar.getInstance();
cal.setTime(timestamp);
cal.add(Calendar.DATE, 2);
Date compareDate = cal.getTime();
if (timestamp.before(compareDate()) return false;
else return true;

It's not Perl, but ...




Hi all,

I am handling timestamps in one of my beans.  Can someone advise me on
how to write the following script?  I am curious about what libraries
you would be using... I am only using "java.util.Date" and it is not
very flexible.

Function to evaluate a date passed by the function process
----------------------------------------------------------
Boolean process(Date timestamp) {
        If timestamp < (today+2days)
                Return false;
        Else
                Return true;
}
----------------------------------------------------------
Thank you for your consideration.
T Lamine Ba



--
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to