01: /*
02: * @(#)NumberFormatConverter.java 4/10/2007
03: *
04: * Copyright 2002 - 2007 JIDE Software Inc. All rights reserved.
05: */
06:
07: package com.jidesoft.converter;
08:
09: import java.text.NumberFormat;
10: import java.text.ParseException;
11:
12: /**
13: * Converter which converts currency to String and converts it back.
14: */
15: abstract public class NumberFormatConverter extends NumberConverter {
16: public NumberFormatConverter(NumberFormat format) {
17: super (format);
18: }
19:
20: public Object fromString(String string, ConverterContext context) {
21: try {
22: return getNumberFormat().parse(string);
23: } catch (ParseException e) {
24: return null;
25: }
26: }
27:
28: public boolean supportFromString(String string,
29: ConverterContext context) {
30: return true;
31: }
32: }
|