首页 > 其他 > 详细

根据日期时间段获取各个月份

时间:2016-12-28 19:47:45      阅读:190      评论:0      收藏:0      [点我收藏+]

 private String[] getDateArrByMonth(Date startDate, Date endDate) {

  Calendar c = Calendar.getInstance();  

 List<String> list = new ArrayList<String>();  

 SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月");

  for (; startDate.getTime() <= endDate.getTime();) {    

 String _startDate = df.format(startDate);   

   list.add(_startDate);    

 c.setTime(startDate);    

   c.add(Calendar.MONTH, 1);    //加一个月

   startDate = c.getTime();   

}

  String[] ret = new String[list.size()];   

  for (int i = 0; i < list.size(); i++) {    

  ret[i] = list.get(i);   

}

  return ret;  }

根据日期时间段获取各个月份

原文:http://www.cnblogs.com/cuijinlong/p/6230264.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!