public static int roundHalfUp ( final Object obj ) { if ( obj instanceof Short ) { return ( short ) obj ; } if ( obj instanceof Integer ) { return ( int ) obj ; } if ( obj instanceof Long ) { return ( ( Long ) obj ) . intValue ( ) ; } if ( obj instanceof Double ) { return new BigDecimal ( ( double ) obj ) . setScale ( 0 , BigDecimal . ROUND_HALF_UP ) . intValue ( ) ; } if ( obj instanceof Float ) { return new BigDecimal ( ( float ) obj ) . setScale ( 0 , BigDecimal . ROUND_HALF_UP ) . intValue ( ) ; } if ( obj instanceof String ) { return new BigDecimal ( ( String ) obj ) . setScale ( 0 , BigDecimal . ROUND_HALF_UP ) . intValue ( ) ; } throw new ShardingException ( "Invalid value to transfer: %s" , obj ) ; }
Round half up .