[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

change double format

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
0
nphnhi
Asked:
nphnhi
  • 4
1 Solution
 
sciuriwareCommented:
Use a DecimalFormat with 2 digits behind the .
<*>
0
 
sciuriwareCommented:
            DecimalFormat fmt = new DecimalFormat("###0.##");

String out = fmt.format(value);
<*>
0
 
sciuriwareCommented:
And back to double could be:
     double d = fmt.parse(out).doubleValue();
<*>
0
 
sciuriwareCommented:
OK
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now