日期:2014-05-17 浏览次数:20808 次
//假设传过来一个字符串日期time,形式如:2011-07-21 String strs[] = time.split("-"); Calendar calendar = Calendar.getInstance(); int year = Integer.parseInt(strs[0]); int month = Integer.parseInt(strs[1]) - 1; calendar.set(year, month, 1); int maxDay = calendar.getMaximum(Calendar.DAY_OF_MONTH); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List<Object> datas = new ArrayList<Object>(); for (int j=1; j<=maxDay; j++) { calendar.set(year, month, j); time = sdf.format(calendar.getTime()); datas.add(time); }
------解决方案--------------------