Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » NumberFormat ter and zero
NumberFormat ter and zero [message #598760] Mon, 07 December 2009 22:33 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
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 17:32 Go to previous message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
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);
}
}
Previous Topic:NumberFormat ter and zero
Next Topic:CDateTime up\down arrow issue
Goto Forum:
  


Current Time: Sun May 19 06:45:39 GMT 2019

Powered by FUDForum. Page generated in 0.01462 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top