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.
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.
The folowing link of java util API can provide help.
http://72.5.124.55/j2se/1.5.0/docs/api/java/util/GregorianCalendar.html#add(int,%20int)
There was another DateUtility which was posted earlier on this site. Please refer that too.
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.