We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 53f630b commit 7dba2aeCopy full SHA for 7dba2ae
src/com/xxdb/data/Utils.java
@@ -72,9 +72,22 @@ public static int countMonths(int days){
72
return year * 12 + month -1;
73
}
74
75
-
+
76
public static YearMonth parseMonth(int value){
77
- return YearMonth.of(value/12, value % 12 +1);
+ int year = value / 12;
78
+ int month = value % 12 + 1;
79
+ if (value < 0){
80
+ Calendar c = Calendar.getInstance();
81
+ int curYear = c.get(Calendar.YEAR);
82
+ int curMonth = c.get(Calendar.MONTH) + 1;
83
+ month = curMonth - Math.abs(month);
84
+ year = curYear - (Math.abs(year % curYear));
85
+ if (month <= 0 ){
86
+ month = 12 - Math.abs(month);
87
+ year--;
88
+ }
89
90
+ return YearMonth.of(year, month);
91
92
93
public static int countDays(LocalDate date){
0 commit comments