toPrimitiveInt()

Converts an object or primitive data type to the primitive int data type.

Syntax

int toPrimitiveInteger(Object objectData)
int toPrimitiveInteger(float floatData)
int toPrimitiveInteger(double doubleData)

Parameters

objectData
A Java object. The objects currently supported are: Double, Float, Integer, and String.
floatData
Any primitive float variable.
doubleData
Any primitive double variable.

Return values

Returns a primitive int value.

Exceptions

DtpIncompatibleFormatException - If the source data type cannot be converted to integer.

Notes

This method can only handle String, Integer, Float, and Double objects; and there will be some data loss when the input type is Fload or Double.

The limitation of this method is the same as the limitation of the int type in Java.

The largest positive hexidecimal and octal literals of type int are 0xfffffff and 017777777777, respectively, which equal 2147483647 (231-1). The most negative hexadecimal and octal literals of type int are 0x80000000and 020000000000, respectively, each of which represents the decimal value -2147483648 (-231). The hexadecimal and octal literals 0xfffffff and 037777777777, respectively, represent the decimal value -1.

Examples

int myInt = DtpDataConversion.toPrimitiveInt(myObject);

See also

getType(), isOKToConvert(), toInteger()

For more information, see the Java Language Specification.

Copyright IBM Corp. 2004, 2005