datatypeconverter.java

来自「这是一个轻便的j2ee的web应用框架,是一个在多个项目中运用的实际框架,采用s」· Java 代码 · 共 50 行

JAVA
50
字号
/*
 * Created on 2004-2-27
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.esimple.framework.util;

import java.math.BigDecimal;
/**
 * @author steven
 *
 */
public class DataTypeConverter {
	public static int toInt(String value) throws ConvertException{
		try {
			int intValue = new Integer( value ).intValue();
			return intValue;
		} catch (Exception e) {
			throw new ConvertException("can not convert String "+ value +" to int");
		}
		
	}
	public static float toFloat(String value) throws ConvertException{
		try {
			return  new Float( value ).floatValue();
		} catch (Exception e) {
			throw new ConvertException("can not convert String "+ value +" to float");
		}
		
	}
	public static double toDouble(String value) throws ConvertException{
		try {
			return  new Double( value ).doubleValue();
		} catch (Exception e) {
			throw new ConvertException("can not convert String "+ value +" to float");
		}
		
	}
	
	public static BigDecimal toBigDecimal(String value) throws ConvertException{
		try {
			return  new BigDecimal(value);
		} catch (Exception e) {
			throw new ConvertException("can not convert String "+ value +" to float");
		}
		
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?