public class JavaNumberFormatTest extends TestCase {
public void testGetJavaNumberFormatter() {
try {
JavaNumberFormat javaNumberFormat = new JavaNumberFormat("#,000");
IJavaFormattedNumber javaFormattedNumber = javaNumberFormat
.formatNumber(9.9);
String value = javaFormattedNumber.getFormattedNumber();
Assert.assertEquals("9,900", value);
javaNumberFormat = new JavaNumberFormat("#,0#");
javaFormattedNumber = javaNumberFormat.formatNumber(1234.567);
value = javaFormattedNumber.getFormattedNumber();
Assert.assertEquals("1234,57", value);
javaNumberFormat = new JavaNumberFormat(
"[<=4][GR�N]#.##0,00 \"�C kalt\";[>7][ROT]#.##0,00 \"�C\";[BLAU]#.##0,00 \"�C\"");
javaFormattedNumber = javaNumberFormat.formatNumber(-10);
value = javaFormattedNumber.getFormattedNumber();
Assert.assertEquals("-10,00 �C kalt", value);
Assert
.assertEquals(Color.GREEN, javaFormattedNumber
.getTextColor());
javaNumberFormat = new JavaNumberFormat(
"[<=4][GR�N]#.##0,00 \"�C kalt\";[>7][ROT]#.##0,00 \"�C\";[BLAU]#.##0,00 \"�C\"");
javaFormattedNumber = javaNumberFormat.formatNumber(10);
value = javaFormattedNumber.getFormattedNumber();
Assert.assertEquals("10,00 �C", value);
Assert.assertEquals(Color.RED, javaFormattedNumber.getTextColor());
} catch (Exception exception) {
exception.printStackTrace();
Assert.fail(exception.getMessage());
}
}