Map<String, Object> data = new HashMap<>();
List<Map<String, Object>> List1 = tMapper.getList()
data.put("AList", List1 );
Map<String, List<mdl>> resultMap = new HashMap<>();
List<mdl> list2 = sMapper.getList();
resultMap.put("A", list2 );
JAVA对日期时间的处理函数:
private Map<String, String> GetDateInfo(String sYear)
{
//这里根据年份传入,获得开始日期和截止日期
String dateBegin = "";
String dateEnd = "";
String dateBeginLast = ""; //上一年开始
String dateEndLast = ""; //上一年截至
Integer maxMonth;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
Calendar cd = new GregorianCalendar();
cd.setTime(new Date());
Integer curYear = cd.get(Calendar.YEAR);
if(Integer.parseInt(sYear) == curYear) //本年
{
Integer curMonth = cd.get(Calendar.MONTH) + 1; //这里月份是从0开始计算的,也就是说,月份是从0—11。
if(curMonth == 1) //1月份比较特殊,如果当前月是1月份,则查去年1整年了
{
cd.add(Calendar.MONTH,-1);
sYear = Integer.toString(cd.get(Calendar.YEAR));
}
}
if(Integer.parseInt(sYear) >= curYear)
{
dateBegin = Integer.toString(curYear) + "-01";
cd.add(Calendar.MONTH,-1);
dateEnd = format.format(cd.getTime());
dateBeginLast = Integer.toString(curYear - 1) + "-01";
cd.add(Calendar.YEAR,-1);
dateEndLast = format.format(cd.getTime());
maxMonth = cd.get(Calendar.MONTH) + 1; //获得截至的月份,这里月份是从0开始计算的,也就是说,月份是从0—11。
}
else
{
dateBegin = sYear + "-01";
dateEnd = sYear + "-12";
dateBeginLast = (Integer.parseInt(sYear) - 1) + "-01";
dateEndLast = (Integer.parseInt(sYear) - 1) + "-12";
maxMonth = 12;
}
Map<String, String> retMap = new HashMap<>();
retMap.put("sYear",sYear);
retMap.put("dateBegin",dateBegin);
retMap.put("dateEnd",dateEnd);
retMap.put("dateBeginLast",dateBeginLast);
retMap.put("dateEndLast",dateEndLast);
String sMaxMonth = String.format("%02d", maxMonth); //必须补全2位数才可以
retMap.put("maxMonth", sMaxMonth);
return retMap;
}