[ Back | Previous | Next ]

How to apply patterns with NumberFormats?

Package:
java.text.*
Product:
JDK
Release:
1.1.x
Related Links:
DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat
Comment:
protected void setValue(Object value) {
	Class vClass = value.getClass();
	String format = (String) getCellFormats().getAttributeTable().get(vClass);
	if (format == null) {
		setText((value == null) ? "" : value.toString());
	} else {
		if (vClass == Integer.class || vClass == Double.class || vClass == Long.class) {
			DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
			df.applyPattern(format);
			setText(df.format(value));
		} else
			if (vClass == Date.class) {
			} else {
			}
	}
}