Hi all,

I want to create a function that adds certain amount of days for a given date.

e.g.

Say today's date is 21/9/2007. and I would like to add 95 days to this date. How do I accomplish that.

Any help will be real appreciate it.

Regards.

Recommended Answers

All 2 Replies

You will want to use Calendar (or perhaps specifically GregorianCalendar) class for that. This site has a lot of info on using it: http://mindprod.com/jgloss/calendar.html
Adding time (days, weeks, months, whatever) is a simple matter of using the add() method or the roll() method depending on your needs. Calendar now = Calendar.getInstance(); will give you a locale-specific instance of a Calendar set to the current date and time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.