Solved

Java Currency

Posted on 2014-12-15
2
60 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Saving Tweets with emojis using Twitter4J in a Mysql table 2 73
Starting to learn JAVA, 7 59
print map entry 34 53
reverse digits of a number using for loop 5 36
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

929 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

10 Experts available now in Live!

Get 1:1 Help Now