Solved

Java Currency

Posted on 2014-12-15
2
65 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
even odd program using while loop 3 74
throw exception 21 68
Is there a simpler dropbox system? 10 44
Selenium docs api java index 3 68
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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.

726 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