/**
* 获取指定日期之间的所有日期list 工作日和周末
* @param start
* @param end
* @return List<List>
*/
private Map getDaysMap(Date start,Date end){
Map rsmap = new HashMap();
List gzrList = new ArrayList();//工作日
List zmList = new ArrayList();//周末
long ldays = 0;
if(start!=null && end!=null){
Calendar c = Calendar.getInstance();
c.setTime(start);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
start = c.getTime();
//
c.setTime(end);
c.set(Calendar.HOUR_OF_DAY, 23);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.SECOND, 59);
c.set(Calendar.MILLISECOND, 999);
end = c.getTime();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if(start.getTime()<=end.getTime()){
//判断相隔的天数
ldays = (end.getTime()-start.getTime())/(1000*24*60*60) + 1;
for(int i=0;i<ldays;i++)
{
Date d = getNextDay(start,i);
String str = df.format(d);
System.out.print(str);
c.setTime(d);
int dw = c.get(Calendar.DAY_OF_WEEK);
if(dw==Calendar.SUNDAY || dw==Calendar.SATURDAY){
zmList.add(transToStr(d));
System.out.println(" 周末");
}
else{
gzrList.add(transToStr(d));
System.out.println(" 工作日");
}
}
}
}
rsmap.put("1", gzrList);
rsmap.put("2", zmList);
return rsmap;
}
posted on 2010-08-30 13:52
David1228 阅读(345)
评论(0) 编辑 收藏 所属分类:
JAVA