public static List<String> calTimeFormat() { int i =0; Calendar ca = Calendar.getInstance();//得到一个Calendar的实例 List<String> timeList = new ArrayList<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); while (i>=-6){ ca.setTime(new Date()); //设置时间为当前时间 ca.add(Calendar.DATE, i); String format = sdf.format( ca.getTime()); timeList.add(format); i--; } return timeList; }