Hi
I am doing something similar, but I want to go on from there day by day. Here is an example of what I am doing
import java.util.*;
public class
test {
static public void main(String args[])
{
Calendar d1 = convertToDate("20001205");
Calendar d2 = convertToDate("20001231");
while(d1.getTime().getTime()<=d2.getTime().getTime())
{
int month = d1.get(Calendar.MONTH)+1;
int dayOfMonth = d1.get(Calendar.DAY_OF_MONTH);
d1.set(Calendar.DAY_OF_MONTH, d1.get(Calendar.DAY_OF_MONTH)+1);
String dateString = new Integer(d1.get(Calendar.YEAR)).toString();
if(month<10)
dateString = dateString + "0";
dateString = dateString + month;
if(dayOfMonth<10)
dateString = dateString + "0";
dateString = dateString + dayOfMonth;
System.out.println("ADDING :" +dateString);
}//emnd while
}//end main
static public Calendar convertToDate(String date)
{
Calendar d = new GregorianCalendar();
d.set(new Integer(date.substring(0, 4)).intValue(),(new Integer(date.substring(4, 6)).intValue())-1,new Integer(date.substring(6, 8)).intValue(),9,9);
return d;
}
}
This outputs
ADDING :20001221
ADDING :20001222
ADDING :20001223
ADDING :20001224
ADDING :20001225
ADDING :20001226
ADDING :20001227
ADDING :20001228
ADDING :20001229
ADDING :20001230
ADDING :20011231
It works fine most of the time, but if you look at what it says for the last output, it goes to 20011231 instead of 20001231. Does anyone know why it goes to 2001. I've tried setting a default time that is during the day and that doesnt fix it.
Any help would be appreciated
Damien