java - Finding date before given number of months from a given date -


i have date e.g. current date 19/04/2013

and have number of months given e.g. 10

i want find out date falling before 10 months 19/04/2013.

how achieve in java?

for example, if want find out date before week, can achieve below:

calendar calendar = calendar.getinstance(); calendar.settime(mydate); calendar.add(calendar.day_of_year, -7); date newdate = calendar.gettime(); 

but how find same months ?

well, similar example:

calendar calendar = calendar.getinstance(); calendar.settime(mydate); calendar.add(calendar.month, -10); date newdate = calendar.gettime(); 

it'll set newdate date 10 months before mydate.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -