You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2020/05/29 18:43:00 UTC

[jira] [Comment Edited] (CAMEL-15137) Duration converter does not parse the seconds fraction correctly

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

Claus Ibsen edited comment on CAMEL-15137 at 5/29/20, 6:42 PM:
---------------------------------------------------------------

This is not a bug, as Camels shorthand format is not fraction based. You use 5s for 5000 millis, But if you want 5500 millis, then you cannot do 5.5s. Instead you can do 5s500ms, or just numeric only with 5500.

The shorthand is less ideal for small values, but great for even values 90s, or 5m30s etc.


was (Author: davsclaus):
This is not a bug, as Camels shorthand format is not fraction based. You use 5s for 5000 millis, But if you want 5500 millis, then you cannot do 5.5s. Instead you do 5s500ms.

The shorthand is less ideal for small values, but great for 90s, or 5m30s etc.

> Duration converter does not parse the seconds fraction correctly
> ----------------------------------------------------------------
>
>                 Key: CAMEL-15137
>                 URL: https://issues.apache.org/jira/browse/CAMEL-15137
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core
>            Reporter: Omar Al-Safi
>            Priority: Major
>             Fix For: 3.4.0
>
>
> In the [DurationConverter|https://github.com/apache/camel/blob/master/core/camel-base/src/main/java/org/apache/camel/converter/DurationConverter.java], there are some edge cases are not handled correctly when fractions being used, e.g: {{DurationConverter.toDuration("5s").toMillis()}} will give the correct value of {{5000}} meanwhile {{DurationConverter.toDuration("5.5s").toMillis()}} will give {{5005}} which is wrong. Here is list of some edge cases:
> * {{DurationConverter.toDuration("5.5s").toMillis()}} -> 5001
> * {{DurationConverter.toDuration("0.01s").toMillis()}} -> 1
> * {{DurationConverter.toDuration("0.1").toMillis()}} -> 1
> * {{DurationConverter.toDuration("0.5s").toMillis()}} -> 5



--
This message was sent by Atlassian Jira
(v8.3.4#803005)