another convert double to string question

   public double roundDouble(double d, int places)
    {
        return Math.round(d * Math.pow(10, (double) places)) / Math.pow(10, (double) places);
    }


    public static void main(String[] args)
     {
        Double testd = new Double(1.129219589E7);
        double testdd = testd.doubleValue();
        test tclass = new test();
        testdd = tclass.roundDouble(testdd,2);
        System.out.println( String.valueOf(testdd)  );
        //also tried Double.toString(testdd)
     }


The problem is i want it to output "11292195.89" instead of "1.129219589E7"

i cannot change the source: new Double(1.129219589E7).  This is something we get in a feed/api. So i need to convert 1.129219589E7 to 11292195.89. but HOW? thank you!
LVL 1
gagaliyaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
System.out.println( String.format("%.2f", testdd)  );
0
CEHJCommented:
Or

System.out.printf("%.2f\n", testdd);
0
gagaliyaAuthor Commented:
hey cehj, thanks for the quick response! your first reply is what i am looking for -need it as a variable (to be used elsewhere). but i got the following complilation error:

//tried lower case String.format() as well
test.java:21: cannot resolve symbol  
symbol  : method Format (java.lang.String,double)
location: class java.lang.String
        System.out.println( String.Format("%.2f", testdd) );

looked up the javadoc for string, seems there is no function named format()?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

hoomanvCommented:
you need java 1.5 for this purpose
0
CEHJCommented:
Lowercase 'f'

System.out.println( String.format("%.2f", testdd) );

but that will only work in >= 1.5

0
CEHJCommented:
Else

DecimalFormat nf = new DecimalFormat("0.00");
String f = nf.format(testdd);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hoomanvCommented:
use java.text.Class NumberFormat instead
0
gagaliyaAuthor Commented:
We wont be moving to 1.5 for a while. Your last solution worked flawlessly, thank you!
0
CEHJCommented:
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.