commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (Closed) (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (LANG-743) JavaDoc bug in static inner class DateIterator
Date Wed, 28 Dec 2011 07:06:30 GMT

     [ https://issues.apache.org/jira/browse/LANG-743?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Henri Yandell closed LANG-743.
------------------------------

       Resolution: Fixed
    Fix Version/s: 3.2

Thanks Patrick. I've updated the javadoc to state that the endFinal parameter is inclusive
in r1225117.
                
> JavaDoc bug in static inner class DateIterator
> ----------------------------------------------
>
>                 Key: LANG-743
>                 URL: https://issues.apache.org/jira/browse/LANG-743
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.time.*
>    Affects Versions: 2.6
>            Reporter: Patrick Arnoldy
>            Priority: Minor
>              Labels: DateIterator, DateUtils
>             Fix For: 3.2
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> 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) {
>     super();
>     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();
> }
> Example:
> 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message