Article View: borland.public.jbuilder.java.api
Article #1386Re: How to add days to todays date?
From: Alex Colic
Date: Mon, 11 Feb 2002 21:02
Date: Mon, 11 Feb 2002 21:02
34 lines
1871 bytes
1871 bytes
Thanks,
I didn't notice I was using 'mm' instead of 'MM.' Works fine now.
Alex
"Gillmer J. Derge" <spam@gillmerderge.com> wrote in message
news:3c682269$1_2@dnews...
> "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:
<3c683111$1_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!newsfeed.frii.com!out.nntp.be!propagator-SanJose!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3c68189b$1_2@dnews> <3c682269$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 13:07:32 PST From: "Alex Colic" <Alex.Colic@pop-ware.com> Newsgroups: borland.public.jbuilder.java.api References: <3c68189b$1_2@dnews> <3c682269$1_2@dnews> Subject: Re: How to add days to todays date? Date: Mon, 11 Feb 2002 16:02:13 -0500 Lines: 36 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: <3c683111$1_1@dnews> X-Trace: dnews 1013461265 24.150.151.67 (11 Feb 2002 13:01:05 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!newsfeed.frii.com!out.nntp.be!propagator-SanJose!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews