February 21st, 2003, 10:05 AM
incrementing the date
Is there any way I can increment the day by one? Here is what I have at the moment:
However, I get a type mismatch error. (cannot convert from long to java.util.Date)
Any suggestions, please? (This is for a loop in which I check the dates to see if they are weekdays, in case you want some context!)
February 21st, 2003, 01:57 PM
long dayLengthInMillis = (long)(24*60*60*1000);
Date newDate = new Date(startDate.getTime() + dayLengthInMillis);
February 23rd, 2003, 04:16 AM
Look at Calendar and JulianCalendar
Most methods to actually change the date exist in the Calendar class and its subclasses.
February 25th, 2003, 01:25 PM
Thanks very much Nemi
ahuimanu - thanks I am aware of the Calendar class, but I was sure there was a way of succeeding in the way I was attempting! I may actually switch over to the Calendar class later on
February 25th, 2003, 03:52 PM
Just as an aside, if you are running that in any kind of long loop it will be very inefficient since you are making a lot of new temp objects.