优化工具类
This commit is contained in:
@@ -155,7 +155,6 @@ public class Tools {
|
|||||||
return new SimpleDateFormat("yyyy-MM").format(cal.getTime());
|
return new SimpleDateFormat("yyyy-MM").format(cal.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前月份的前6个月(含当前月)
|
* 获取当前月份的前6个月(含当前月)
|
||||||
* @param size 月数
|
* @param size 月数
|
||||||
@@ -176,41 +175,6 @@ public class Tools {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前月份的前6个月(含当前月)
|
|
||||||
* @param date
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<String> getSixMonth(String date) {
|
|
||||||
List<String> list = new ArrayList<String>();
|
|
||||||
int month = Integer.parseInt(date.substring(5, 7));
|
|
||||||
int year = Integer.parseInt(date.substring(0, 4));
|
|
||||||
for (int i = 5; i >= 0; i--) {
|
|
||||||
if (month > 6) {
|
|
||||||
if (month - i >= 10) {
|
|
||||||
list.add(year + "-" + String.valueOf(month - i));
|
|
||||||
} else {
|
|
||||||
list.add(year + "-0" + String.valueOf(month - i));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (month - i <= 0) {
|
|
||||||
if (month - i + 12 >= 10) {
|
|
||||||
list.add(String.valueOf(year - 1) + "-" + String.valueOf(month - i + 12));
|
|
||||||
} else {
|
|
||||||
list.add(String.valueOf(year - 1) + "-0" + String.valueOf(month - i + 12));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (month - i >= 10) {
|
|
||||||
list.add(String.valueOf(year) + "-" + String.valueOf(month - i));
|
|
||||||
} else {
|
|
||||||
list.add(String.valueOf(year) + "-0" + String.valueOf(month - i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 截取字符串长度
|
* 截取字符串长度
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user