• Post Reply Bookmark Topic Watch Topic
  • New Topic

thousands-separators  RSS feed

 
Ryan Ryszka
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how I can get rid of the Thousands-separator in a Long data type object? I have looked all over NumberFormat, and can not find a function to accomplish this. Any help would be appreciated.

Thanks,
Ryan
 
Siripa Siangklom
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Peter van der Linden
author
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

how can I get rid of the Thousands-separator in a Long data type object?
I have looked all over NumberFormat, and can not find a function to accomplish this.


It doesn't work quite like you think it does.
You generally don't want to use NumberFormat, unless you are happy with the
default format for your locale, which you are not.

You want to specify your own format, one without "," separators.

Take a look at the API for java.text.DecimalFormat. There is a constructor that
takes a String arg that lets you specify how you want the number to look.
That is the one you want.

Cheers,

Peter
 
Ryan Ryszka
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found something that worked, I guess I will follow up on my own post:

NumberFormat format = NumberFormat.getInstance();
format.setGroupingUsed(false);
System.out.println(format.format(trans.getEmployeeNum()));
System.out.println(format.format(trans.getEmployeeNum()));

the setGroupingUsed was the key, thanks to all who replied!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!