[Java Code] 时间维度循环生成代码片段
public static void main(String[] args) throws ParseException { String str = "20140301"; String str1 = "20140731"; SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); Calendar start = Calendar.getInstance(); Calendar end = Calendar.getInstance(); try { start.setTime(format.parse(str)); end.setTime(format.parse(str1)); } catch (ParseException e) { e.printStackTrace(); } while (start.before(end)) { System.out.println(format.format(start.getTime())); start.add(Calendar.DAY_OF_MONTH, 1); } }
谨言慎行,专注思考 , 工作与生活同乐