Results 1 to 4 of 4
- 03-18-2011, 08:49 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 7
- Rep Power
- 0
Display a '%' when using String.format( )
I am writing a program where I need to display the percent symbol '%' in a GUI using String.format( ). Since % is used as the indicator to place args in the String I can't figure out how to display '%'.
example:
float percent = 20;
String Sentence = String.format("You are %,.2f done.", percent);
this would only display 20.00
How do I get it to display like 20.00% ????
Thanks.
- 03-18-2011, 08:59 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Use %%
Or format only the first part and append the restJava Code:String Sentence = String.format("You are %,.2f%% done.", percent);
;DJava Code:String Sentence = String.format("You are %,.2f", percent)+ "% done";
- 03-18-2011, 10:17 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 7
- Rep Power
- 0
Exactly what I needed!
Thanks!!!
- 03-18-2011, 11:01 PM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Similar Threads
-
how to display data in a table format using jstl tag
By anand12356 in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 02-09-2011, 01:26 PM -
how to set display format into a column in jTable?
By newbiejava in forum New To JavaReplies: 1Last Post: 07-27-2010, 04:54 PM -
What is the different between Text format display on web browser and display on midle
By Basit781 in forum CLDC and MIDPReplies: 1Last Post: 05-31-2010, 08:46 AM -
Java Locale Date Display Diff Format Prob
By hemanthjava in forum Advanced JavaReplies: 2Last Post: 03-05-2009, 02:05 PM -
Date format display in CSV file after exporting
By latha in forum Advanced JavaReplies: 0Last Post: 08-03-2007, 08:09 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks