Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Programmer > Re: java.text.D...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 52615 of 55513
Post > Topic >>

Re: java.text.DecimalFormat problems

by RedGrittyBrick <RedGrittyBrick@[EMAIL PROTECTED] > May 9, 2008 at 10:28 PM

zamba wrote:
> Hi....i have this value in a resultset called ConceptsDataRes:
> 
> BASE_CALCULO=0.0001 and i wish to convert to string , so i use
> 
> String CantFormat ="###,##0.0#";
> java.text.DecimalFormat dCantFormat = new
> java.text.DecimalFormat(CantFormat);
> dCantFormat.format(ConceptsDataRes.getDouble("BASE_CALCULO"));
> 
> but it shows me 0.0 ....whats the problem ?

0.0001 to two decimal places is 0.0

> 
> also in the ame resultset i have the value
> 
> MONTO=299.00 and i wish to convert to string so i use
> 
> String CantFormat ="###,##0.00";
> java.text.DecimalFormat dCantFormat = new
> java.text.DecimalFormat(CantFormat);
> dCantFormat.format(ConceptsDataRes.getDouble("MONTO"));
> 
> but it shows me 299.0 ....whats the problem ?
> 

It shows me 299.00 - your actual program must differ from the code you 
posted. See http://sscce.org/

--------------------------- 8< -------------------------------
im****t java.text.DecimalFormat;
public class DFTest {
     public static void main(String[] args) {
         format(0.0001, "###,##0.0#");
         format(0.006,  "###,##0.0#");
         format(0.01,   "###,##0.0#");
         format(299.0,  "###,##0.00");
     }
     static void format(double d, String f) {
         System.out.println(new DecimalFormat(f).format(d));
     }
}
--------------------------- 8< -------------------------------
0.0
0.01
0.01
299.00


-- 
RGB
 




 3 Posts in Topic:
java.text.DecimalFormat problems
zamba <CRISTIAN_FERRER  2008-05-09 13:36:26 
Re: java.text.DecimalFormat problems
Dave Miller <dave@[EMA  2008-05-09 21:04:01 
Re: java.text.DecimalFormat problems
RedGrittyBrick <RedGri  2008-05-09 22:28:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 18:16:06 CST 2008.