Z
zamba
hi, i want to know how to convert a doble value like this 98.34 to
string 00009834 or 9.34 to 00000934 thanks a lot !!!!!
string 00009834 or 9.34 to 00000934 thanks a lot !!!!!
zamba said:hi, i want to know how to convert a doble value like this 98.34 to
string 00009834 or 9.34 to 00000934 thanks a lot !!!!!
zamba said:thank you , but i read link and i tried to use NumberFormat , but i
can't get an example how to use exactly the way i need...
zamba said:hi, i want to know how to convert a doble value like this 98.34 to
string 00009834 or 9.34 to 00000934 thanks a lot !!!!!
Tim Slattery said:Check out the DecimalFormat class.
zamba said:hi, i want to know how to convert a doble value like this 98.34 to
string 00009834 or 9.34 to 00000934 thanks a lot !!!!!
But to follow up: You would not format 98.34 to display as "00009834"Hal Rosser said:I think it goes something like this:
assume you have a double n with a value of 9.34 which you want to display
as 009.34 string.
NumberFormat nf = NumberFormat.getNumberInstance();
//set the min digits before the decimal
nf.setMinimumIntegerDigits(3);
//set min digits after decimal
nf.setMinimumFractionalDigits(2);
String numberToShow = nf.format(n);
//numberToShow will be your string
zamba said:thank you , but i read link and i tried to use NumberFormat , but i
can't get an example how to use exactly the way i need...
Andreas said:I guess, it would be easier, if he(zamba) first multiplied with
100, and then used some integral format.
Hal said:But to follow up: You would not format 98.34 to display as "00009834"
because then it would not be the same number.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.