AI DataViewer
Dataviewer News Certification Pricing Blog
About Us Contact Us Privacy Policy
signup login
×

Talend Data Types - Convert STRING data type to other data types

In Talend's tMap component, you can convert a String data type to several other data types. Here's a table showing the conversions and examples:

Target Data TypeConversion MethodExample
BooleanBoolean.valueOf(string)Boolean.valueOf("true") results in true
ByteByte.valueOf(string)Byte.valueOf("123") results in 123
ShortShort.valueOf(string)Short.valueOf("123") results in 123
IntegerInteger.valueOf(string)Integer.valueOf("123") results in 123
LongLong.valueOf(string)Long.valueOf("123") results in 123L
FloatFloat.valueOf(string)Float.valueOf("123.45") results in 123.45f
DoubleDouble.valueOf(string)Double.valueOf("123.45") results in 123.45d
BigDecimalnew BigDecimal(string)new BigDecimal("123.45") results in 123.45
DateTalendDate.parseDate("yyyy-MM-dd", string)TalendDate.parseDate("yyyy-MM-dd", "2023-06-17") results in June 17, 2023

Please note that when converting a string to a date, you need to specify the date format. In the example provided, the date format is "yyyy-MM-dd". If your date string is in a different format, you'll need to adjust the format string accordingly. Also, these conversions will throw a NumberFormatException or ParseException if the string cannot be parsed to the target data type.