[ 
https://issues.apache.org/jira/browse/LANG-1762?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17913066#comment-17913066
 ] 

Gary D. Gregory commented on LANG-1762:
---------------------------------------

The pattern would also apply to the stop-instant.

 

> 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
>            Assignee: Gary D. Gregory
>            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