IBM WebSphere Multichannel Bank Transformation Toolkit, Version 7.1

Implementing a type converter

Converters transform business objects to Strings (formatting) and Strings to business objects (unformatting).

A converter can have conversion parameters when converting the type to or from String. For example, a converter for Date type can have pattern parameter, which defines the format of a date String in ‘YYYY-MM-DD' or ‘MM-DD-YYYY' or other formats.

A technical developer does not need to implement a converter from scratch. WebSphere® Multichannel Bank Transformation Toolkit provides com.ibm.btt.base.types.impl.BaseConverter as superclass of all converter implementations. A technical developer can extend the class and override the format and the unformat methods. The format method:
public abstract String format(K value, T params, String convType, Locale locale)
			throws DSETypeException;
The unformat method:
public abstract K unformat(String value, T params, String convType, Locale locale)
			throws DSETypeException;
Shown below is simple code of implementing the two methods:
public String format(TimeZone value,
			com.ibm.btt.base.types.impl.BaseConverter.FormatParamBeam params,
			String convType, Locale locale) throws DSETypeException {
		// TODO Auto-generated method stub
		//in the formate of:  GMT Sign TwoDigitHours : Minutes
		return value.getID();
	}

	@Override
	public TimeZone unformat(String value,
			com.ibm.btt.base.types.impl.BaseConverter.FormatParamBeam params,
			String convType, Locale locale) throws DSETypeException {
		// TODO Auto-generated method stub
		//in the formate of:  GMT Sign TwoDigitHours : Minutes
		return TimeZone.getTimeZone(value);
	}


Feedback