commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Arnoldy (JIRA)" <>
Subject [jira] [Created] (LANG-743) JavaDoc bug in static inner class DateIterator
Date Fri, 19 Aug 2011 08:18:27 GMT
JavaDoc bug in static inner class DateIterator

                 Key: LANG-743
             Project: Commons Lang
          Issue Type: Bug
          Components: lang.time.*
    Affects Versions: 2.6
            Reporter: Patrick Arnoldy
            Priority: Minor

Possibly there is a bug in the JavaDoc comment of the DateIterator constructor. It says, that
the parameter endFinal is not included in the date range that will be iterated, but when I
look at the source code I see that the end date will be delivered as a result of the next()-method.

Source code:
 * Constructs a DateIterator that ranges from one date to another. 
 * @param startFinal start date (inclusive)
 * @param endFinal end date (not inclusive)
DateIterator(Calendar startFinal, Calendar endFinal) {
    this.endFinal = endFinal;
    spot = startFinal;
    spot.add(Calendar.DATE, -1);

 * Has the iterator not reached the end date yet?
 * @return <code>true</code> if the iterator has yet to reach the end date
public boolean hasNext() {
    return spot.before(endFinal);

 * Return the next calendar in the iteration
 * @return Object calendar for the next date
public Object next() {
    if (spot.equals(endFinal)) {
        throw new NoSuchElementException();
    spot.add(Calendar.DATE, 1);
    return spot.clone();

Value of variable endFinal: 2011-08-20
Current value of variable spot: 2011-08-19

- hasNext returns true because spot is before endFinal
- the if-statement fails because spot is not equal to endFinal
- one day is added to spot
- next returns the 20th of august => endFinal

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message