Java将⽇期拆分成按周或⽉时间段统计
/**
* 根据传⼊的参数,来对⽇期区间进⾏拆分,返回拆分后的⽇期List
* @param statisticsType
* @param map
* @return
* @throws ParseException
* @author lihq 2019-6-24
* @editor
* @editcont
*/
public List<String>doDateByStatisticsType(String statisticsType,Map<String, Object> map)throws ParseException{
List<String> listWeekOrMonth =new ArrayList<String>();
DateFormat dateFormat =new SimpleDateFormat("yyyy-MM-dd");
String startDate =(("startDate");
String endDate =(("endDate");
Date sDate = dateFormat.parse(startDate);
Calendar sCalendar = Instance();
sCalendar.setFirstDayOfWeek(Calendar.MONDAY);
sCalendar.setTime(sDate);
Date eDate = dateFormat.parse(endDate);
Calendar eCalendar = Instance();
eCalendar.setFirstDayOfWeek(Calendar.MONDAY);
eCalendar.setTime(eDate);
boolean bool =true;
if(statisticsType.equals("week")){
Time().getTime()&Time().getTime()){
if(bool||(Calendar.DAY_OF_WEEK)==2||(Calendar.DAY_OF_WEEK)==1){
listWeekOrMonth.add(dateFormat.Time()));
bool =false;
}
sCalendar.add(Calendar.DAY_OF_MONTH,1);
}
listWeekOrMonth.add(dateFormat.Time()));
if(listWeekOrMonth.size()%2!=0){
listWeekOrMonth.add(dateFormat.Time()));
}
java时间日期格式转换
}else{
Time().getTime()&Time().getTime()){
if(bool||(Calendar.DAY_OF_MONTH)==1||(Calendar.DAY_OF_MONTH)==ActualMaximum(Calendar.D AY_OF_MONTH)){
listWeekOrMonth.add(dateFormat.Time()));
bool =false;
}
sCalendar.add(Calendar.DAY_OF_MONTH,1);
}
listWeekOrMonth.add(dateFormat.Time()));
if(listWeekOrMonth.size()%2!=0){
listWeekOrMonth.add(dateFormat.Time()));
}
}
return listWeekOrMonth;
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。