🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1384

How to add days to todays date?

#1384
From: Alex Colic
Date: Mon, 11 Feb 2002 19:17
16 lines
1325 bytes
Hi,

I am trying to write a simple method that returns todays date + 30. So far I
have the following:

  SimpleDateFormat now=new SimpleDateFormat ("yyyy-mm-dd");
  Calendar c = Calendar.getInstance();
  c.setTime(new Date());
  c.add(Calendar.DATE,days);
  return now.format(c.getTime());

I think it should work but it is giving me incorrect dates like: 2002-13-15.

Could someone please set me straight.

Alex
Technical Details
Message-ID: <3c68189b$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!howland.erols.net!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,7bbd6e93e7c14885,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-02-11 11:17:36 PST
From: "Alex Colic" <Alex.Colic@pop-ware.com>
Newsgroups: borland.public.jbuilder.java.api
Subject: How to add days to todays date?
Date: Mon, 11 Feb 2002 14:17:51 -0500
Lines: 18
Organization: PopWare Inc
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
NNTP-Posting-Host: 24.150.151.67
Message-ID: <3c68189b$1_2@dnews>
X-Trace: dnews 1013455003 24.150.151.67 (11 Feb 2002 11:16:43 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!howland.erols.net!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews