Article View: borland.public.jbuilder.java.api
Article #1385Re: How to add days to todays date?
From: Gillmer J. Derge
Date: Mon, 11 Feb 2002 19:59
Date: Mon, 11 Feb 2002 19:59
23 lines
1548 bytes
1548 bytes
"Alex Colic" <Alex.Colic@pop-ware.com> wrote in message
news:3c68189b$1_2@dnews...
> 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.
Try using your format to show the value of today's date, new Date(). That
will reveal a lot. :-)
Your format string is printing year-*minutes*-date. I think you want to
use "yyyy-MM-dd".
-----
Gillmer J. Derge
Technical Details
Message-ID:
<3c682269$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3c68189b$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,7bbd6e93e7c14885 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2002-02-11 12:11:21 PST From: "Gillmer J. Derge" <spam@gillmerderge.com> Newsgroups: borland.public.jbuilder.java.api References: <3c68189b$1_2@dnews> Subject: Re: How to add days to todays date? Date: Mon, 11 Feb 2002 14:59:33 -0500 Lines: 26 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 24.29.81.241 Message-ID: <3c682269$1_2@dnews> X-Trace: dnews 1013457513 24.29.81.241 (11 Feb 2002 11:58:33 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews