1.import java.text.ParseException;
2.import java.text.SimpleDateFormat;
3.import java.util.Calendar;
4.import java.util.Date;
5.
6.public class CalenderTest1 {
7.
8. public static void main(String[] args) {
9. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
10.
11. Calendar calendar = Calendar.getInstance();
12. Date mydate = new Date();
13. try {
14. mydate = sdf.parse("201003");
15. } catch (ParseException e) {
16. e.printStackTrace();
17. }
18. calendar.setTime(mydate);
19. calendar.add(Calendar.MONTH, -1);
20.
21. System.out.println(sdf.format(calendar.getTime()));
22.
23. }
24.
25.}
2.import java.text.SimpleDateFormat;
3.import java.util.Calendar;
4.import java.util.Date;
5.
6.public class CalenderTest1 {
7.
8. public static void main(String[] args) {
9. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
10.
11. Calendar calendar = Calendar.getInstance();
12. Date mydate = new Date();
13. try {
14. mydate = sdf.parse("201003");
15. } catch (ParseException e) {
16. e.printStackTrace();
17. }
18. calendar.setTime(mydate);
19. calendar.add(Calendar.MONTH, -1);
20.
21. System.out.println(sdf.format(calendar.getTime()));
22.
23. }
24.
25.}