L
laredotornado
Hi,
I'm using Java 1.6 on Mac 10.6.3. I'm trying to get the closest
Sunday before today, unless today is Sunday in which case I don't want
to change my calendar object. Here is what I have ...
cal.set(Calendar.DAY_OF_MONTH, 1);
while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
cal.add(Calendar.DAY_OF_YEAR, -1);
out.println("\t<!-- iterating through cal:" +
cal.getTime().toString() + "-->");
}
However, this loop is consistently returning a calendar instance that
is Saturday. Any ideas of something obvious that I'm missing here?
Thanks for your help, - Dave
I'm using Java 1.6 on Mac 10.6.3. I'm trying to get the closest
Sunday before today, unless today is Sunday in which case I don't want
to change my calendar object. Here is what I have ...
cal.set(Calendar.DAY_OF_MONTH, 1);
while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
cal.add(Calendar.DAY_OF_YEAR, -1);
out.println("\t<!-- iterating through cal:" +
cal.getTime().toString() + "-->");
}
However, this loop is consistently returning a calendar instance that
is Saturday. Any ideas of something obvious that I'm missing here?
Thanks for your help, - Dave