package com.sinitek.framework.util;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2011-5-23
* Time: 16:09:26
* To change this template use File | Settings | File Templates.
*/
public class JdbcQueryUtils
{
/**
* 转Double
* @param object
* @return
*/
public static Double convertToDouble( Object object )
{
if ( object == null )
return null ;
if ( object instanceof BigDecimal )
{
return ( ( BigDecimal )object ).doubleValue( ) ;
}
return null ;
}
/**
* 转String
* @param object
* @return
*/
public static String convertToString( Object object )
{
if ( object == null )
return null ;
if ( object instanceof String )
{
return object.toString( ) ;
} else {
return String.valueOf(object);
}
}
/**
* 转Integer
* @param object
* @return
*/
public static Integer convertToInteger( Object object )
{
if ( object == null )
return null ;
if ( object instanceof BigDecimal )
{
return ( ( BigDecimal )object ).intValue( ) ;
}
return null ;
}
/**
* 转Date
* @param object
* @return
*/
public static Date convertToDate( Object object )
{
if ( object == null )
return null ;
if ( object instanceof Timestamp )
{
return new Date( ( ( Timestamp )object ).getTime( ) ) ;
}
return null ;
}
}