commit
825e1c7a42
@ -704,10 +704,7 @@ public class DepotItemController {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
try {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
|
||||
String dateString = formatter.format(date);
|
||||
List<String> list = Tools.getSixMonth(dateString);
|
||||
List<String> list = Tools.getLastMonths(6);
|
||||
map.put("monthList", list);
|
||||
List<BigDecimal> buyPriceList = new ArrayList<BigDecimal>();
|
||||
for(String month: list) {
|
||||
|
||||
@ -155,6 +155,27 @@ public class Tools {
|
||||
return new SimpleDateFormat("yyyy-MM").format(cal.getTime());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前月份的前6个月(含当前月)
|
||||
* @param size 月数
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getLastMonths(int size) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(new Date());
|
||||
List<String> list = new ArrayList(size);
|
||||
for (int i=0;i<size;i++) {
|
||||
c.setTime(new Date());
|
||||
c.add(Calendar.MONTH, -i);
|
||||
Date m = c.getTime();
|
||||
list.add(sdf.format(m));
|
||||
}
|
||||
Collections.reverse(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前月份的前6个月(含当前月)
|
||||
* @param date
|
||||
|
||||
Loading…
Reference in New Issue
Block a user