How to transform a string to an integer

Hi, My name is Joaquin,
I am a beginners and I want to know how to transform a string to any other type of data.:frowning:

Hmmm. More detail is needed.

Is it that you want to work with an Integer, Float, Double, etc. and are not happy with the IS String type?

If so, you can add an input or output of type Object and then specify the Java type in the properties to be whatever you need. Then you will be working directly with an Integer, Double, Float, etc.

You can also specify an input or output of type String and constrain its content type to be an Integer, etc. Then you are working with a String, but it must contain something that meets the content type qualification.

Both of the above options are in the properties for the variable.

Or do you have a string and need to convert it to something else?

In this case, you would likely want to take advantage of built-in services that might help (such as stringToBytes) or write a custom Java service that converts to the desired type (and catches the potential exceptions if the data is not valid for that type.)

My problem is:
I have a table in Oracle, which has since types of data as integer, date, decimal, I want to do is convert a string of these types of data:(:o

So you are inserting into Oracle or selecting from Oracle? Are you using JDBC adapter services?

If you are using JDBC adapter services, then a select template service will return an int if that is the datatype, and an object for things like date and decimal. An insert template service handles them the same. It will then be your responsibility to convert those to string (using Java) or from a string (using Java) when you call the adapter service.

So you’ll likely need to read up on what you need to do in a Java service to convert from string to your data type and vice versa.

For example, to convert a string to date, use SimpleDateFormat.parse(stringContainingDate).

To convert the simple types (such as double, integer, float) use the valueOf method for each simple type, such as Integer.valueOf(stringContainingInteger).

I would offer that keeping vars as strings, even when using adapter services, is the way to go. The one exceptions may be dates, where converting to/from a java.util.Date type may be more easily managed than strings following a particular format (though that can be effective too). The adapter will manage the conversions for you. The only time I ever convert to types other than strings is when calculations are needed.

P.S. Avoid the use of float/double for dollar values. Using those data types can lead to accuracy errors.