This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
hi, this is praveen, now i have one problem before me. "I need to display 3 days less than current date". this we can do manually by getting current date & subtracting that from 3. this is fine if date is in a month or year but when month or year is changed then we need to write lot of code. so pls help me if any one know's simple solution for this. thank u.
The Calendar class can do this, and if you use disable the lenient parsing, it will handle the situations you describe too I believe:
Note that according to the API docs the Calendar version of roll is broken, but the overridden version in GregorianCalendar does the right thing. Thats why I didn't declare cal to be a Calendar in the code above.