Displaying decimals in Java without trailing zeros
<p>I came across this problem, I have a number of type long which represents time (only seconds and miliseconds). I would like to display it for example like this <code>1,124 ms</code>. I thought that simple division would do the job, so I tried this code</p>

<pre><code> long time = 2;
 System.out.println(((float) time) / 1000);
</code></pre>

<p>But when the number has only one digit like in the example above, it's giving me <code>0,0020</code>. So is there a way how to correct my formula or I have to manually cut the last zero?</p>
