subtracting days from GregorianCalendar


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: subtracting days from GregorianCalendar

  1. #1
    Join Date
    Feb 2005
    Posts
    31

    subtracting days from GregorianCalendar

    Hi there,

    How does one subtract, let's say, 7 days from a given GregorianCalendar instance. Let's say I want to set up two instances on GregorianCalendar. The first one has a known date, like so:

    int endYear = 2005;
    int endMonth = 7;
    int endDay = 6;
    GregorianCalendar endDate = new GregorianCalendar();
    endDate.set(endYear,endMonth,endDay);

    How do I set up a second instance of GregorianCalendar set to 7 days prior to the endDate instance?
    GregorianCalendar nearDate = new GregorianCalendar();
    ...
    ...

    What I want to do here is make a comparison with todays date (a third instance of GregorianCalendar that is set to todays date), to see if todays date is within the range between endDate and nearDate.

    Can someone please help?

    Alan

  2. #2
    Join Date
    Dec 2003
    Location
    tx/us
    Posts
    131
    Check out the methods add(), after() and before().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center