0

I am trying convert String value into Double. But toDouble() automatically removing 0 from output value. If String value is "1.30" then after conversion toDouble() returns 1.3.

val value = String.format(
            "%02d.%02d",
            TimeUnit.MILLISECONDS.toHours(milli) % 24,
            TimeUnit.MILLISECONDS.toMinutes(milli) % 60
        )
    return value.toDouble()```

Input value : "1.30"
Retuned value : 1.3
Expected value : 1.30


Thanks in advance.
  • 3
    1.3, 1.30, 1.300, 1.3000 is all the same – Ivo Feb 10 '23 at 11:56
  • Does this answer your question? [How to convert double to string with no zero absent in kotlin?](https://stackoverflow.com/questions/74236305/how-to-convert-double-to-string-with-no-zero-absent-in-kotlin) – Ivo Feb 10 '23 at 12:04
  • I want to return value in "double" type only... – Saurabh G. Feb 13 '23 at 09:40

0 Answers0