This is fairly simple one. You can use Java's Calendar class to achieve this.
Calendar now = Calendar.getInstance();
System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1) + "-"
+ now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR));
// Remove 30 days to current date using Calendar.add method
now.add(Calendar.DATE, -30);
System.out.println("date before 30 days : " + (now.get(Calendar.MONTH) + 1) + "-"
+ now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR));
// Remove 30+ days to current date using Calendar.add method
now.add(Calendar.DATE, -40);
System.out.println("date before 30+ days : " + (now.get(Calendar.MONTH) + 1) + "-"
+ now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR));
Try that and let us know.