You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/12/10 11:50:00 UTC

[jira] [Commented] (LANG-1761) StopWatch: Undeprecate ``getTime``

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

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

I can understand the desire to keep the old API. I am OK with this change but I personally would not use the API in my apps.
FYI, the general idea is:
Using an API that does not define its scale in its name can lead to bugs. Is it seconds, milliseconds, or something else?
- OTHO, Java now has {{java.time}} package, no mistake is possible when you use these types.
- Duration gives you more precision on modern Java platforms.

> StopWatch: Undeprecate ``getTime``
> ----------------------------------
>
>                 Key: LANG-1761
>                 URL: https://issues.apache.org/jira/browse/LANG-1761
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.time.*
>    Affects Versions: 3.16.0, 3.17.0
>            Reporter: AB-xdev
>            Assignee: Gary D. Gregory
>            Priority: Major
>
> The StopWatch {{getTime}} method [was deprecated in 3.16.0|https://github.com/apache/commons-lang/blob/08988a2c9029b1625115b3e3c6d30cb0fd1de57a/src/changes/changes.xml#L132-L135].
> We have some problems with the deprecation and would like to have it reverted:
> * We're unable to find the exact reasons for the deprecation because there is no issue/PR with further explanation. So for us it is not comprehensible.
> * {{getTime}} is a lot shorter as writing {{getDuration().toMillis()}} or {{getTime(TimeUnit.MILLISECONDS)}}
> * According to our tests {{getTime}} is around 10% faster than {{getDuration().toMillis()}} (as it just divides 2 longs instead of instantiating a new object)
> * The method has been present for the last 22 years and is well established. Changing it would result in a lot of code changes for us.
>  



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