Controller
@RequestMapping(value = "add.json",method = {RequestMethod.GET})
public List add(HttpServletResponse response, HttpServletRequest request
) {
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
List<Date> list = new ArrayList<>();
Calendar start = Calendar.getInstance();
start.set(1915, 10, 30,00,00,00);
Long startTIme = start.getTimeInMillis();
Calendar end = Calendar.getInstance();
end.set(2050, 12, 31);
Long endTime = end.getTimeInMillis();
int days = getDiffDays(new Date(startTIme),new Date(endTime));
Long oneDay = 1000 * 60 * 60 * 24l;
Long time = startTIme;
while (time <= endTime) {
Date d = new Date(time);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
String a = df.format(d);
time += oneDay;
list.add(new Date(time));
}
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("ids", list);
int a = withdrawalLogManager.add(paramMap);
return list;
} catch (Exception e) {
e.printStackTrace();
}
XML:
<insert id="add" parameterType="java.util.Map">
insert into system_day(create_time) VALUES
<foreach collection="ids" item="managerId" index="index" separator=",">
(#{managerId,jdbcType=DATE})
</foreach>
</insert>