Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: date + 90 days

Reply
Thread Tools

Re: date + 90 days

 
 
Wayne
Guest
Posts: n/a
 
      07-31-2003
Marco Schmidt wrote:
> [XaToA]:
>
>
>>SimpleDateFormat fechabase = new SimpleDateFormat("yyyy-MM-dd H:mm:ss.S");
>>String ahora = fechabase.format(new Date());
>>
>>how can i sum to ahora 90 days?

>
>
> Add 90L * 86000L * 1000L to System.currentMillis() and then create a
> Date from that long value. Then you can format the Date in whatever
> way you need.
>
> Regards,
> Marco


I think this will work too:

Calendar cal = Calendar.getInstance();
cal.add( Calendar.DATE, 90 );
Date d = cal.getTime();
ahora = fechabase.format( d );

-Wayne

 
Reply With Quote
 
 
 
 
PeterV
Guest
Posts: n/a
 
      08-09-2003
Makes me realise the value of operator overloading in C++ - it is so much
easier and intuitive for date calculations such as this....

"Wayne" <> wrote in message news:bga316$ba2$...
> Marco Schmidt wrote:
> > [XaToA]:
> >
> >
> >>SimpleDateFormat fechabase = new SimpleDateFormat("yyyy-MM-dd

H:mm:ss.S");
> >>String ahora = fechabase.format(new Date());
> >>
> >>how can i sum to ahora 90 days?

> >
> >
> > Add 90L * 86000L * 1000L to System.currentMillis() and then create a
> > Date from that long value. Then you can format the Date in whatever
> > way you need.
> >
> > Regards,
> > Marco

>
> I think this will work too:
>
> Calendar cal = Calendar.getInstance();
> cal.add( Calendar.DATE, 90 );
> Date d = cal.getTime();
> ahora = fechabase.format( d );
>
> -Wayne
>



 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Thomas_Gagn=E9?=
Guest
Posts: n/a
 
      08-11-2003
PeterV wrote:

>Makes me realise the value of operator overloading in C++ - it is so much
>easier and intuitive for date calculations such as this....
>

Makes me appreciate the simplicity of OO languages like Smalltalk:

aDate addDays: 90.

--
..tom
remove email address' dashes for replies
opensource middleware at <http://isectd.sourceforge.net>
http://gagne.homedns.org


 
Reply With Quote
 
Marco Schmidt
Guest
Posts: n/a
 
      09-05-2003
PeterV:

>Makes me realise the value of operator overloading in C++ - it is so much
>easier and intuitive for date calculations such as this....


No, that's more of an API problem. There could easily be a method
addDays(int num) which would be perfectly self-explanatory. On the
other hand, what would + mean? Add seconds, minutes, days, months?

Regards,
Marco
--
Please reply in the newsgroup, not by email!
Java programming tips: http://jiu.sourceforge.net/javatips.html
Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date calculator, add or subtract days to or from a given date dlx_son@yahoo.com Javascript 8 06-26-2005 09:21 PM
Calculate the date after subtracting nmbr of days form a date Laery C Programming 11 02-25-2005 07:59 AM
Calculating days using Business Days for the Calendar David Stockwell Python 2 09-20-2004 09:58 PM
Re: Calculating days using Business Days for the Calendar Gerrit Python 0 09-20-2004 04:39 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57