1 public static void main(String[] args) throws ParseException { 2 // 方法一 3 // Format f = new SimpleDateFormat("yyyy-MM-dd"); 4 // 5 // Date today = new Date(); 6 // System.out.println("今天是:" + f.format(today)); 7 // 8 // Calendar c = Calendar.getInstance(); 9 // c.setTime(today); 10 // c.add(Calendar.DAY_OF_MONTH, 1);// 今天+1天 11 // 12 // Date tomorrow = c.getTime(); 13 // System.out.println("明天是:" + f.format(tomorrow)); 14 15 // 方法二 16 List<NutMap> maps = new ArrayList<NutMap>(); 17 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); 18 Calendar cal = Calendar.getInstance(); 19 cal.setTime(new Date()); 20 int sum = 3; 21 int i = 0; 22 for (int j = 0; j < sum ; j++) { 23 cal.add(cal.DATE, 1); 24 if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { 25 sum++; 26 } else { 27 NutMap map = new NutMap(); 28 map.addv("data" + i, format.format(cal.getTime())); 29 i++; 30 maps.add(map); 31 } 32 } 33 System.out.println(maps); 34 }