Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsNumberFormat ter and zero
https://www.eclipse.org/forums/index.php/mv/msg/188748/598760/#msg_598760
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...]]>Dennis Melzer2009-12-07T22:33:09-00:00Re: NumberFormat ter and zero
https://www.eclipse.org/forums/index.php/mv/msg/188748/598765/#msg_598765
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);
}
}]]>Dennis Melzer2009-12-08T17:32:20-00:00