Solved

Java Currency

Posted on 2014-12-15
2
63 Views
Last Modified: 2015-01-05
Hi,

How can I make this line show in currency

so like $300.00

lblP2.setText(Double.toString(pay2));

Open in new window

0
Comment
Question by:Computer Guy
  • 2
2 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 40501969
Something like this should do it...

lblP2.setText(String.format("$%.02f", pay2));

Open in new window

0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 40501973
Or perhaps this may be more correct (ie. might handle different locales more correctly), but may be overkill for what you want...

lblP2.setText(NumberFormat.getCurrencyInstance().format(pay2));

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 212
eclipse shortcuts 9 62
tomcat not starting 6 62
How to convert from xls to xlsx using java 7 52
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

789 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