× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This fragment is not very elegant, but it does the trick (calculating the
days between two dates including a 'window' either side)...
        ...
        GregorianCalendar gcFrom = new GregorianCalendar();
        GregorianCalendar gcTo = new GregorianCalendar();
        GregorianCalendar gc = new GregorianCalendar();


        gcFrom.setTime(arrivalDate);
        gcFrom.add(Calendar.DATE, -arrivalWindow);
        windowFromDate = gcFrom.getTime();


        gcTo.setTime(departureDate);
        gcTo.add(Calendar.DATE, departureWindow);
        windowToDate = gcTo.getTime();

        // Calculate the number of days (nights stayed) between the two dates
        gc.setTime(windowFromDate);

        while (true) {
                gc.add(Calendar.DATE, 1);
                if (!gc.after(gcTo)) {
                        numberOfDays++;
                }
                else {
                        break;
                }

        }
        ...

Hope this helps...

CJ


-----Original Message-----
From: java400-l-admin@midrange.com
[mailto:java400-l-admin@midrange.com]On Behalf Of Robert Upshall
Sent: Thursday, January 10, 2002 1:30 PM
To: java400-l@midrange.com
Subject: Re: how to calculate #days between dates


Does anybody have an example of how to use those classes or does anybody
know of an example online.

I just looked at those classes and I'm a little unsure of  what I'd need to
do.


----- Original Message -----
From: "Mike Silvers" <msilvers@hbs-inc.com>
To: <java400-l@midrange.com>
Sent: Thursday, January 10, 2002 2:55 PM
Subject: Re: how to calculate #days between dates


> use the Calendar class....
>
> ================================
>
> Mike Silvers
> AS/400 Senior Programmer/Analyst
> AS/400 IBM Certified RPG IV Developer
> AS/400 IBM Certified Expert
> Hainey Business Systems
> 8 E. Canal St
> Dover, PA 17315
> Branch Office:  (410) 397-8739
> Phone:  (800) 932-3380
> Fax:  (717) 292-9474
> Web: http://www.hbs-inc.com
> ________________________________
> Providing E-Commerce, EDI, AS/400
> Development and related services
> nationwide.
> ================================
> ----- Original Message -----
> From: Robert Upshall <rupshall@psasoft.com>
> To: <java400-l@midrange.com>
> Sent: Thursday, January 10, 2002 3:43 PM
> Subject: how to calculate #days between dates
>
>
> > I have 2 dates, 8-digit BigDecimal, CCYYMMDD format, is there an easy
way
> to
> > use the java Date classes to calculate the # of days between the dates?
> >
> > Robert Upshall
> > Professional Software of Amarillo
> > (806) 358-8928
> > rupshall@psasoft.com
> >
> >
> > _______________________________________________
> > This is the Java Programming on and around the iSeries / AS400
(JAVA400-L)
> mailing list
> > To post a message email: JAVA400-L@midrange.com
> > To subscribe, unsubscribe, or change list options,
> > visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
> > or email: JAVA400-L-request@midrange.com
> > Before posting, please take a moment to review the archives
> > at http://archive.midrange.com/java400-l.
> >
> >
>
>
> _______________________________________________
> This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
 mailing list
> To post a message email: JAVA400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
> or email: JAVA400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>

_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.