This content has been marked as final. Show 4 replies
I checked it but I couldn't get what I want !
I checked it but I couldn't get what I want !The API documentation includes an example of the code used to
format a number in different ways. It also includes a link to Sun's
tutorial on the subject.
Perhaps you could post a small example using the techniques
illustrated that shows your problem. If it doesn't compile cut and post
the error message (and indicate the offending lines). If it does compile
but doesn't display "1.00", say what it does display.
I just want to explain what did I do, to help other people
I imported these classes:
import java.text.DecimalFormat; import java.text.NumberFormat;
then, I defined 2 variables:
NumberFormat formatter = new DecimalFormat("0.00"); String s; double timer=0; // the variable I want to change its format
I made some operations on "timer" and then
s = formatter.format(timer);
finally, to display it: