首页 > 代码库 > 开始日期结束日期获取中间所有月份

开始日期结束日期获取中间所有月份

    public long[] findCustomerCoReg(StatisticsQuery query){        

     Date startDate = query.getStartDate();        

     Date endDate = query.getEndDate();        

     Calendar c = Calendar.getInstance();        

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

            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");

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

            Map<String, Object> params = new HashMap<String, Object>();            

            String _startDate = df.format(startDate);            

                   c.setTime(startDate);            

        c.add(Calendar.WEEK_OF_MONTH, 1);            

                   startDate = c.getTime();            

                   String _endDate = df.format(startDate);            

                   params.put("startDate", _startDate);            

                   params.put("endDate", _endDate);            

                   long l = customerMapper.findCustomerCoReg(params);            

                  list.add(l);        

           }       

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

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

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

            }

                 return ret;    

}

开始日期结束日期获取中间所有月份