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

Alonso Gonzalez updated LANG-1762:
----------------------------------
    Description: 
{{getStartTime()}} and {{getStopTime()}} were deprecated in 3.16.0 but the new 
methods don't use the new fields startInstant and stopInstant directly. Instead 
the new methods delegate to the deprecated methods.

Thus calling the new {{getStartTime()}} method means:
 * call deprecated method {{getStartTime()}}
 * extract millis from available Instant startInstant
 * create a new Instant with the extracted millis

The new methods should use the existing instants directly and the deprecated 
methods should delegate to the new methods:
{code:java}
    public Instant getStartInstant() {
        if (runningState == State.UNSTARTED) {
            throw new IllegalStateException("Stopwatch has not been started");
        }
        return startInstant;
    }

    @Deprecated
    public long getStartTime() {
        return getStartInstant().toEpochMilli();
    }
{code}
This would avoid unnecessary object creation.

  was:
{{getStartTime()}} and {{getStopTime()}} were deprecated in 3.16.0 but the new 
methods don't use the new fields startInstant and stopInstant directly. Instead 
the new methods delegate to the deprecated methods.

Thus calling the new {{getStartTime()}} method means:
 * call deprecated method {{getStartTime()}}
 * extract millis from available Instant startInstant
 * create a new Instant with the extracted millis

The new methods should use the existing instants directly and the deprecated 
methods should delegate to the new methods:
{code:java}
    public Instant getStartInstant() {
        if (runningState == State.UNSTARTED) {
            throw new IllegalStateException("Stopwatch has not been started");
        }
        return startInstant;
    }

    @Deprecated
    public long getStartTime() {
        return getStartInstant().toEpochMilli();
    }
{code}
This would avoid unnecessary object creations.


> New StopWatch methods should not delegate to deprecated methods
> ---------------------------------------------------------------
>
>                 Key: LANG-1762
>                 URL: https://issues.apache.org/jira/browse/LANG-1762
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.time.*
>    Affects Versions: 3.16.0, 3.17.0
>            Reporter: Alonso Gonzalez
>            Priority: Major
>
> {{getStartTime()}} and {{getStopTime()}} were deprecated in 3.16.0 but the 
> new methods don't use the new fields startInstant and stopInstant directly. 
> Instead the new methods delegate to the deprecated methods.
> Thus calling the new {{getStartTime()}} method means:
>  * call deprecated method {{getStartTime()}}
>  * extract millis from available Instant startInstant
>  * create a new Instant with the extracted millis
> The new methods should use the existing instants directly and the deprecated 
> methods should delegate to the new methods:
> {code:java}
>     public Instant getStartInstant() {
>         if (runningState == State.UNSTARTED) {
>             throw new IllegalStateException("Stopwatch has not been started");
>         }
>         return startInstant;
>     }
>     @Deprecated
>     public long getStartTime() {
>         return getStartInstant().toEpochMilli();
>     }
> {code}
> This would avoid unnecessary object creation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to