NumberFormat ter and zero [message #598760] |
Mon, 07 December 2009 17:33  |
Eclipse User |
|
|
|
Hello
i want a NumberFormatter , which can show zeros but if the textfield is empty, it shouldn't show a zero to start.
This one almost works, but it doesn't show a string which start with "0,00"
The Textfield shows ",00". how can i get the first zero?
NumberFormatter formatter = new NumberFormatter("#,###,###.##");
formatter.setFixedLengths(false, true);
Thanks for any idea...
|
|
|
Re: NumberFormat ter and zero [message #598765 is a reply to message #598760] |
Tue, 08 December 2009 12:32  |
Eclipse User |
|
|
|
I solved it so:
public class MoneyFormatter extends NumberFormatter{
public MoneyFormatter(String string) {
super(string);
}
@Override
protected int format(int curseur) {
if (editValue.toString().equals(EMPTY)) {
zeroIntLen = 0;
} else if (editValue.toString().equals("0")) {
zeroIntLen = 1;
} else if (editValue.toString().equals(
"0" + symbols.getDecimalSeparator())) {
zeroIntLen = 1;
} else if (editValue.toString().startsWith(
String.valueOf(symbols.getDecimalSeparator()))) {
zeroIntLen = 1;
}
return super.format(curseur);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.08297 seconds