Code snippet for this would really help
Well, in the big picture its going to help you less
(see
this)
Have a look at the Calendar class and notice that there are methods to rollback a calender by a particular amount for a particular field (minute, hour, day, year etc.). Also notice there are methods to get the maximum value a particular field can hold.