class Test {
public static void main(String args[]) {
Date newDate = new Date("20030404"); //将字符串"20030404"转化为一个Date
system.out.println("The date is :" + newDate );
}
}
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2003-4-4
* Time: 11:53:30
* To change this template use Options | File Templates.
*/
import java.util.Calendar;
import java.util.Vector;
import java.text.SimpleDateFormat;
public class test {
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2003-4-4
* Time: 11:53:30
* To change this template use Options | File Templates.
*/
import java.util.Calendar;
import java.util.Vector;
import java.text.SimpleDateFormat;
public class test {
public static void main(String args[]){
Calendar scal = Calendar.getInstance();
Calendar cal = Calendar.getInstance();
Vector list=new Vector();
String str="";
int syear=2003,smonth=4,sday=9;
int eyear=2004,emonth=2,eday=7;
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
for(int m=sday;m<((eyear-syear)*12+(emonth-smonth)+(eday-sday)+1);m++){
cal.set(syear,smonth,m);
str=formatter.format(cal.getTime()) ;
list.addElement(str);
}
}
}
//有了list,剩下的不用我说了吧
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
List list = new ArrayList();
Date date1 = calendar1.getTime();
date1.setTime(date1.getTime()+(long)24*60*60*1000);
while(!(format.format(date1)).equals(str2)){
list.add(format.format(date1));
date1.setTime(date1.getTime()+(long)24*60*60*1000);
}
String[] result = new String[list.size()];
list.toArray(result);
for(int i=0;i<result.length;i++){
System.out.println(result[i]);
}