Results 1 to 2 of 2
- 04-07-2014, 11:08 PM #1
Member
- Join Date
- Apr 2014
- Location
- Miami, FL
- Posts
- 47
- Rep Power
- 0
A question about the NumberFormat class
Hi I just have a quick question
How come I can do this from the NumberFormat class
float miles = 534.433434323F;
String milesFormatted = NumberFormat.format(miles);
System.out.println(milesFormatted);
but not
float miles = 534.433434323F;
String milesFormatted = NumberFormat.getNumberInstance(3).format(miles);
System.out.println(milesFormatted);
I would appreciate a complete explanation of this concept. Thank you very much.
- 04-08-2014, 12:40 AM #2
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: A question about the NumberFormat class
I'm not certain what you are trying to do. Also, in the second example you are passing a integer to the getNumberInstance() method. That integer represents a Locale. Is that what you intended?
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
Similar Threads
-
NumberFormat Class Question
By SoullessWhale in forum New To JavaReplies: 1Last Post: 10-22-2012, 12:07 PM -
A (very) simple question about NumberFormat in Applet
By calnastic in forum New To JavaReplies: 2Last Post: 06-17-2011, 04:34 AM -
NumberFormat which leave fractions as they are
By itaipee in forum AWT / SwingReplies: 2Last Post: 12-09-2009, 07:11 PM -
using numberformat
By roaan in forum New To JavaReplies: 3Last Post: 07-02-2009, 05:28 AM -
NumberFormat is abstract?
By DrKush in forum New To JavaReplies: 4Last Post: 03-27-2009, 08:54 AM
Bookmarks