日期:2014-05-19 浏览次数:20805 次
import java.util.*;
import java.text.*;
public class Test {
public static void main(String[] args) throws Exception {
GregorianCalendar[] ga=getDate("2012-08-01", "2012-08-15");
for(GregorianCalendar e:ga)
{
// System.out.println(e.get(Calendar.YEAR)+"年 "+
// +(e.get(Calendar.MONTH)+1)+"月 "+
// e.get(Calendar.DAY_OF_MONTH)+"号");
System.out.println(eiditime(e));
}
}
/**
*
* @param startTime
* @param endTime
* @return 返回开始时间和结束时间之间的每一日
* @throws ParseException
*/
public static GregorianCalendar[] getDate(String startTime,String endTime) throws ParseException
{
Vector<GregorianCalendar> v=new Vector<GregorianCalendar>();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
GregorianCalendar gc1=new GregorianCalendar(),gc2=new GregorianCalendar();
gc1.setTime(sdf.parse(startTime));
gc2.setTime(sdf.parse(endTime));
do{
GregorianCalendar gc3=(GregorianCalendar)gc1.clone();
v.add(gc3);
gc1.add(Calendar.DAY_OF_MONTH, 1);
}while(!gc1.after(gc2));
return v.toArray(new GregorianCalendar[v.size()]);