[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);
        }
    }

 

posted @ 2015-01-26 17:47  JackyKen  阅读(336)  评论(0编辑  收藏  举报