Solved

Java Currency

Posted on 2014-12-15
2
59 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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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 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 one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

771 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

12 Experts available now in Live!

Get 1:1 Help Now