Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes add days to date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "add days to date" Watch "add days to date" New topic

add days to date

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104


Is there any simple way to add to a Date object 3 days.

I trie to get the milisecons from the date and then create a new date with the miliseconds from the original date adding the miliseconds of threee day but I think there would be something easier.

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2904

Use Calendar class, It has roll() and add() methods , which helps to add() specific field by some value you want. The fields are like DATE, MONTH , etc..

Have look at Calendar class APIfor detailed story !

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
I agree. Here's the link:
subject: add days to date
It's not a secret anymore!