date - Adding one week via java.util.Calendar.add() fails -
i'm trying iterate in java program on weeks between 2 dates (the end date being today). first, starting date:
calendar start = calendar.getinstance(); start = data.getfirstdate(users, threads);
so far, good. start date correct , can work it. iterate:
calendar current = start; while(current.before(calendar.getinstance()) { // current.add(calendar.date, 7); }
well, kind of works. start @ 2002/8/23, comes 2002/8/30, 2002/9/7... until 2002/11/30. date after 2003/0/6, neither correct nor valid date!
what doing wrong? tried current.add(calendar.date, 7)
, current.add(calendar.week_of_year, 1)
, current.add(calendar.day_of_year, 7)
, 2 other ways. using current.roll(calendar.date, 7)
not work because stay in same month. using gregoriancalendar
has no effect well.
any suggestions appreciated!
thanks julian
the month field in calendar
api 0-based not 1-based. 0 stands january. don't ask me why.
Comments
Post a Comment