change double format

Posted on 2004-11-12
Last Modified: 2010-03-31
Hello everyone,
I have a double for ex: 1234.2345 -> I want to change to format: 1234.23 (it is also a double)?
Please help me
Thank you very much
Question by:nphnhi
    LVL 24

    Accepted Solution

    Use a DecimalFormat with 2 digits behind the .
    LVL 24

    Expert Comment

                DecimalFormat fmt = new DecimalFormat("###0.##");

    String out = fmt.format(value);
    LVL 24

    Expert Comment

    And back to double could be:
         double d = fmt.parse(out).doubleValue();
    LVL 24

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    Multiple issues with Java 14 37
    Help refactoring a java code 8 45
    instanceof  operator in java 26 55
    copyEndy  challenge 15 38
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now