package com.rjconsultores.ventaboletos.web.utilerias;

import java.math.BigDecimal;

import org.zkoss.zk.ui.Component;
import org.zkoss.zkplus.databind.TypeConverter;

public class StringToFloatConverter implements TypeConverter {

	public Object coerceToUi(Object val, Component comp) {
		if (val != null) {
			return val;
		}
		return null;
	}

	public Object coerceToBean(Object val, Component cmpnt) {
		if (val == null) {
			return null;
		}

		if (val instanceof String) {

			return (val.toString().trim().isEmpty()) ? null : new BigDecimal(val.toString()).floatValue();
		}
		return null;
	}
}
