日期:2014-05-17 浏览次数:20824 次
String a = "2013.04.29";
String b = "2013.05.10";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
try {
long end = sdf.parse(b).getTime();
long begin = sdf.parse(a).getTime();
while(begin<=end){
Date day = new Date();
day.setTime(begin);
begin += 3600*24*1000;
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/**输入日期格式:2013.04.29*/
public static List getDays(String a, String b) {
List days = new ArrayList();// 日期集合
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
try {
long end = sdf.parse(b).getTime();
long begin = sdf.parse(a).getTime();
while (begin <= end) {
Date day = new Date();
day.setTime(begin);
begin += 3600 * 24 * 1000;
days.add(sdf.format(day));
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return days;
}