Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Dates...

Status
Not open for further replies.

Elton1984

Programmer
Mar 8, 2004
16
Hiz all,
I have a little problem here.. Example: (I'm supposed to add 4 days to today's date (22/6/04) and display the date that is 4 days later.)

Oh ya, is there also a way to display all the dates that between today's date and the date 4 days later??

Anyone have any ideas on hw to get it to work??

Thanx in Advance,
Elton
 
Have you checked the documentation ?

Generally, what you do is :

Code:
long today = (new Date()).getTime();

long oneMinute = 60000L;
long oneHour = oneMinute * 60;
long oneDay = oneHour * 24;

long fourDaysFromToday = (today + (oneDay * 4));

Date newDate = new Date(fourDaysFromToday);

Before you ask about how to parse date strings, please first read the documentation on SimpleDateFormat :


--------------------------------------------------
Free Database Connection Pooling Software
 
Also it is helpful to examine the GregorianCalendar class.With add method of GregorianCalendar you can make several operations.

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
turkey_clr.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top