fixed a process for changing a calendar.
@@ -50,13 +50,29 @@ | ||
50 | 50 | } |
51 | 51 | |
52 | 52 | public void changeCalendarToPrevMonth() { |
53 | - month = String.valueOf(Integer.parseInt(month) - 1); | |
53 | + int oldValue = Integer.parseInt(month); | |
54 | + month = String.valueOf(oldValue - 1); | |
54 | 55 | updateCalendarValue(); |
56 | + int newValue = Integer.parseInt(month); | |
57 | + if (oldValue == newValue) { | |
58 | + // in this case, not change a month. | |
59 | + month = String.valueOf(oldValue - 1); | |
60 | + date = String.valueOf(1); | |
61 | + updateCalendarValue(); | |
62 | + } | |
55 | 63 | } |
56 | 64 | |
57 | 65 | public void changeCalendarToNextMonth() { |
58 | - month = String.valueOf(Integer.parseInt(month) + 1); | |
66 | + int oldValue = Integer.parseInt(month); | |
67 | + month = String.valueOf(oldValue + 1); | |
59 | 68 | updateCalendarValue(); |
69 | + int newValue = Integer.parseInt(month); | |
70 | + if (newValue - oldValue > 1) { | |
71 | + // in this case, skip a next month. | |
72 | + month = String.valueOf(oldValue + 1); | |
73 | + date = String.valueOf(1); | |
74 | + updateCalendarValue(); | |
75 | + } | |
60 | 76 | } |
61 | 77 | |
62 | 78 | private void updateCalendarValue() { |
@@ -46,13 +46,29 @@ | ||
46 | 46 | } |
47 | 47 | |
48 | 48 | public void changeCalendarToPrevMonth() { |
49 | - month = String.valueOf(Integer.parseInt(month) - 1); | |
49 | + int oldValue = Integer.parseInt(month); | |
50 | + month = String.valueOf(oldValue - 1); | |
50 | 51 | updateCalendarValue(); |
52 | + int newValue = Integer.parseInt(month); | |
53 | + if (oldValue == newValue) { | |
54 | + // in this case, not change a month. | |
55 | + month = String.valueOf(oldValue - 1); | |
56 | + date = String.valueOf(1); | |
57 | + updateCalendarValue(); | |
58 | + } | |
51 | 59 | } |
52 | 60 | |
53 | 61 | public void changeCalendarToNextMonth() { |
54 | - month = String.valueOf(Integer.parseInt(month) + 1); | |
62 | + int oldValue = Integer.parseInt(month); | |
63 | + month = String.valueOf(oldValue + 1); | |
55 | 64 | updateCalendarValue(); |
65 | + int newValue = Integer.parseInt(month); | |
66 | + if (newValue - oldValue > 1) { | |
67 | + // in this case, skip a next month. | |
68 | + month = String.valueOf(oldValue + 1); | |
69 | + date = String.valueOf(1); | |
70 | + updateCalendarValue(); | |
71 | + } | |
56 | 72 | } |
57 | 73 | |
58 | 74 | private void updateCalendarValue() { |