Date function
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Blue_Milk
Posted On:   Tuesday, February 26, 2002 05:06 AM

is there anyway to get a specific date after a certain period of time. for example, to get the current system date, i have used this


			
Calendar calendar = Calendar.getInstance();
SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy");
String date = sdf1.format(calendar.getTime());


This would return 26-02-2002. Is there anyway to get the date when it is exactly 3 months later? I.E. 26-05-2002.



p.s. there is a duplicate question in the JMX forum. could the mods remove it or something?

Re: Date function

Posted By:   Anonymous  
Posted On:   Tuesday, February 26, 2002 06:29 AM

Hi i would do it like this:

Date date = new Date();
Date newdate = new Date(date.getYear(), date.getMonth()+3, date.getDate());

Regards, Soren Mathiasen

Re: Date function

Posted By:   George_Tzallas  
Posted On:   Tuesday, February 26, 2002 05:15 AM

Have you checked the
Calendar.add (int, int)
method ? It should answer your question.


Good luck.


George T.

About | Sitemap | Contact