🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8332

Re: Calcs with date

#8332
From: John McGrath TeamB
Date: Sat, 31 Mar 2001 09:05
29 lines
1766 bytes
On Fri, 30 Mar 2001 09:18:56 +0200, icsd.jt@wanadoo.fr wrote:

> From a date I want to calc the date of the 5 next days :
> Madate + 1, Madate +2 ...
> I think It was simple but with class Date and/or GregorianCalendar,
> add() or madate + x .. are not accepted (Method not found.. with the
> imports java.util.GregorianCalendar,java.util.calendar and java.util.date
> or run bad : the give me the same date to 01/01/70 )

With a Date object, you could get the "time" value, which is in 
milliseconds since the epoch, and add the number of milliseconds in a 
day to it.  For example:

   static final int MILLISECONDS_PER_DAY = 1000 * 60 * 60 * 24;
      :
   date.setTime( date.getTime() + MILLISECONDS_PER_DAY );

With a Calendar object, you can use the add() method:

    calendar.add( Calendar.DATE, 1 );

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <MPG.152f440031c959298a0de@forums.borland.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews!209.92.40.60
References: <3ac4333b_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,c3bf18884d79d144
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-31 01:44:02 PST
From: John McGrath  [TeamB] <ng-b@JPMcGrath.net>
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Calcs with date
Date: Sat, 31 Mar 2001 04:05:38 -0500
Message-ID: <MPG.152f440031c959298a0de@forums.borland.com>
References: <3ac4333b_1@dnews>
X-Newsreader: MicroPlanet Gravity v2.30
NNTP-Posting-Host: 209.92.40.60
X-Trace: 31 Mar 2001 01:01:00 -0800, 209.92.40.60
Lines: 29
X-Authenticated-User: jpmcgrath
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews!209.92.40.60