This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I want to get a date which is n days previous to the current date. I want to do it without using the Calender Objet but just by using java.util.Date.
Can any body please help.
pascal betz
Ranch Hand
Joined: Jun 19, 2001
Posts: 547
posted
0
Why do you want to do this without Calendar ?
Date has a constructor taking a long argument which is the number of milliseconds sinse 1.1.1970 (see javadoc). And if you have a Date X where you want to subtract 1 day, then its: oldDate in millis - 1000 * 60 * 60 * 24
make sure the multiplication does not exceed the int range!
pascal
Rohit Dhodapkar
Ranch Hand
Joined: Apr 27, 2006
Posts: 38
posted
0
Hi,
I want to do this stuff in the java script .Can you please advice me how to do it?.
We do have an HTML and Javascript forum here, which the post could be moved to. But Rohit originally asked about Java, then about Javascript. So maybe there is a question about which one Rohit should be using?