Version

    Conversion Functions

    Sometimes you need to convert values from one data type to another.

    In the functions that convert one data type to another, sometimes a format pattern of a date or any number must be defined. Also locale and time zone can have an influence on their formatting.

    • For detailed information about date formatting and/or parsing, see Date and Time Format.

    • For detailed information about formatting and/or parsing of any numeric data type, see Numeric Format.

    • For detailed information about locale, see Locale.

    • For detailed information about time zones, see Time Zone.

    [Note]Note

    Remember that numeric and date formats are displayed using system value Locale or Locale specified in the defaultProperties file, unless other Locale is explicitly specified. Similarly for Time zone.

    For more information on how Locale and Time zone may be changed in the defaultProperties, see Chapter 17, Engine Configuration.

    Here we provide the list of these functions:

    base64byte

    byte base64byte(string input);

    The base64byte() function converts the input string in base64 representation to an array of bytes.

    Its counterpart is the function byte2base64.

    If the input is null, the function returns null.

    Compatibility

    The base64byte(string) function is available since CloverETL 3.0.0.

    Example 67.1. Usage of base64byte

    The function base64byte("YWJj") returns abc.


    See also:  byte2base64

    bits2str

    string bits2str(byte input);

    The bits2str() function converts an array of bytes to a string consisting of two characters: "0" or "1".

    Each byte is represented by eight characters ("0" or "1"). For each byte, the lowest bit is at the beginning of these eight characters. The counterpart is the function str2bits.

    If the input is null, the function returns null.

    Compatibility

    The bits2str(byte) function is available since CloverETL 3.0.0.

    Example 67.2. Usage of bits2str

    The function bits2str(str2byte("ab")) returns 1000011001000110. Let's display the result for better legibility as 1000 0110 0100 0110. The first eight bits are taken from a (code 0x61) and following bits are taken from b (code 0x62).


    See also:  str2bits

    bool2num

    integer bool2num(boolean input);

    The bool2num() function converts the boolean input to either integer 1 (if the argument is true) or integer 0 (if the argument is false).

    If the input is null, the function returns null.

    Compatibility

    The bool2num(boolean) function is available since CloverETL 3.0.0.

    Example 67.3. Usage of bool2num

    The function bool2num(true) returns 1.

    The function bool2num(false) returns 0.


    See also:  num2bool

    byte2base64

    string byte2base64(byte input);

    string byte2base64(byte input, boolean wrap);

    The byte2base64() function converts an array of bytes to a string in base64 representation.

    The function with one input parameter wraps the encoded lines after 76 characters. The ability of the function with 2 parameters to wrap lines is affected by the second parameter. If the wrap parameter is set to true, the encoded lines are wrapped after 76 characters.

    If the input byte array is null, the function returns null.

    Compatibility

    The byte2base64(byte) function is available since CloverETL 3.0.0.

    The byte2base64(byte,boolean) function is available since CloverETL 3.5.0-M2.

    Example 67.4. Usage of byte2base64

    The function byte2base64(str2byte("abc", "utf-8")) returns YWJj. The function str2byte used in the example is needed for conversion of abc from string to bytes as the function byte2base64 needs to have bytes as an argument.


    See also:  base64byte, byte2hex, byte2str

    byte2hex

    string byte2hex(byte input);

    string byte2hex(byte input, string escapeChars);

    The byte2hex() function converts an array of bytes to a string in hexadecimal representation.

    If the input is null, the function returns null.

    The escapeChars are prepended before hexadecimal characters of each byte. If the escapeChars is null, empty string, or the function has only one argument, nothing is escaped.

    Compatibility

    The byte2hex(input) function is available since CloverETL 3.0.0.

    The byte2hex(input,escapeChars) function is available since CloverETL 4.4.1.

    Example 67.5. Usage of byte2hex

    The function byte2hex(str2byte("abc", "utf-8")) returns 616263.

    The function byte2hex(str2byte("abc", "utf-8"),null) returns 616263.

    The function byte2hex(str2byte("abc", "utf-8"),"") returns 616263.

    The function byte2hex(str2byte("abc", "utf-8"),"\\") returns \61\62\63.

    The function byte2hex(str2byte("abc", "utf-8"),"hello") returns hello61hello62hello63.


    See also:  byte2base64, byte2str, hex2byte

    byte2str

    string byte2str(byte payload, string charset);

    The byte2str() function converts an array of bytes to a string using given charset.

    If the charset is null, the function fails with an error. If the payload is null, the function returns null.

    Compatibility

    The byte2str(byte,string) is available since CloverETL 3.2.x.

    Example 67.6. Usage of byte2str

    The function byte2str(hex2byte("616263"), "utf-8") returns string abc.


    See also:  byte2base64, byte2hex, str2byte

    date2long

    long date2long(date input);

    The date2long() function converts a date argument to the long data type.

    The return value is the number of milliseconds elapsed from January 1, 1970, 00:00:00 GMT to the date specified as the argument.

    If the input is null, the function returns null.

    Compatibility

    The date2long(date) function is available since CloverETL 3.0.0.

    Example 67.7. Usage of date2long

    The function date2long(str2date("2009-02-13 23:31:30", "yyyy-MM-dd HH:mm:ss", "en.GB", "GMT+0")) returns 1234567890000.


    See also:  date2num, date2str, long2date

    date2num

    integer date2num(date input, unit timeunit);

    integer date2num(date input, unit timeunit, string locale);

    The date2num() returns the number of specified time units from the date using system or specified locale.

    The date parameter is a date to be converted. If the input date is null, the function returns null.

    The unit of field timeunit can be one of the following: year, month, week, day, hour, minute, second or millisec. The unit must be specified as a constant. It can neither be received through an edge nor set as a variable.

    If the function takes two arguments, it returns an integer using the system locale. If the parameter locale is used, the function uses the locale from the locale parameter instead of the system locale.

    If the time unit is contained in the date, it is returned as an integer number. If it is not contained, the function returns 0.

    [Important]Important

    Remember that months are numbered starting from 1 unlike in CTL1.

    The default time zone is used in the conversion.

    Compatibility

    The date2num(date,unit) and date2num(ate,unit,string) functions are available since CloverETL 3.0.x.

    Example 67.8. Usage of date2num

    The function date2num(2008-06-12, month) returns 6.

    The function date2num(2008-06-12, hour) returns 0.

    The function date2num(long2date(1234567890000L), year, "en.US") returns 2009.

    The function date2num(long2date(1234567890000L), year, "th.TH") returns 2552.


    See also:  date2long, date2str, getYear, getMonth, getDay, getHour, getMinute, getSecond, getMillisecond

    date2str

    string date2str(date input, string pattern);

    string date2str(date input, string pattern, string locale);

    string date2str(date input, string pattern, string locale, string timeZone);

    The date2str() function converts the input date to the string data type according to the specified pattern, locale and target timeZone.

    The input contains date to be converted to the string. If the input date is null, the function returns null.

    The pattern describes date and time format. If the pattern is null, default value is used.

    The locale parameter defines what date format symbols should be used. If the locale is null, an empty string, or the function does not have the locale parameter, the respective default value is used.

    If the timeZone parameter is null, an empty string, or the function does not have the locale parameter, the default time zone value is used.

    Compatibility

    The date2str(date,string) function is available since CloverETL 3.0.0.

    The date2str(date,string,string) function is available since CloverETL 3.0.1.

    The date2str(date,string,string,string) function is available since CloverETL 3.5.0-M1.

    Example 67.9. Usage of date2str

    The function date2str(2008-06-12, "dd.MM.yyyy") returns the following string: "12.6.2008".

    The function date2str(2009-01-04, "yyyy-MMM-d", "fr.CA") returns 2009-janv.-4.

    The function date2str(2009-01-04 12:38:06, "yyyy-MMM-d HH:mm:ss z", "fr.CA", "GMT-5") returns "2009-janv.-4 06:38:06 GMT-05:00" (assuming that the default time zone is GMT+1).


    See also:  date2long, date2num, str2date, getYear, getMonth, getDay, getHour, getMinute, getSecond, getMillisecond

    decimal2double

    number decimal2double(decimal arg);

    The decimal2double() function converts a decimal argument to a double value.

    The conversion is narrowing, and if the decimal value cannot be converted into double (as the range of the double data type does not cover all decimal values), the function fails with an error.

    On the other hand, any double can be converted into decimal. Both Length and Scale of a decimal can be adjusted for it.

    If the input is null, the function returns null.

    Compatibility

    The decimal2double(decimal) function is available since CloverETL 3.0.0.

    Example 67.10. Usage of decimal2double

    The function decimal2double(9007199254740991D) returns 9.007199254740991E15. The input decimal number fit into double precisely.

    The function decimal2double(92378352147483647.23D) returns 9.2378352147483648E16.

    The function decimal2double(9007199254740993D) returns 9.007199254740992E15. The input number is too big to fit into the double data type precisely. Narrowing conversion is used and input decimal number is rounded.


    See also:  decimal2integer, decimal2long, round, roundHalfToEven

    decimal2integer

    integer decimal2integer(decimal arg);

    The decimal2integer() function converts a decimal argument to an integer.

    The conversion is narrowing, and if the decimal value cannot be converted into integer (as the range of the integer data type does not cover the range of decimal values), the function fails with an error.

    On the other hand, any integer can be converted into decimal without a loss of precision. Length of decimal can be adjusted for it.

    If the input is null, the function returns null.

    [Note]Note

    There is no function decimal2integer(double). You can use double parameter of the function due to implicit conversion of double to decimal. If you need conversion from double to integer, use the function double2integer.

    Compatibility

    The decimal2integer(decimal) function is available since CloverETL 3.0.0.

    Example 67.11. Usage of decimal2integer

    The function decimal2integer(352147483647.23D) fails with an error as the input decimal number is out of range of the integer data type.

    The function decimal2integer(25.95D) returns 25.

    The function decimal2integer(-123.45D) returns -123.


    See also:  decimal2double, decimal2long, round, roundHalfToEven

    decimal2long

    long decimal2long(decimal arg);

    The decimal2long() function converts a decimal argument to a long value.

    The conversion is narrowing, and if the decimal value cannot be converted into long (as the range of long data type does not cover all decimal values), the function fails with an error.

    On the other hand, any long can be converted into decimal without loss of precision. Length of a decimal can be adjusted for it.

    If the input is null, the function returns null.

    [Note]Note

    There is no function decimal2long(double). You can use double parameter of the function due to implicit conversion of double to decimal. If you need conversion from double to long, use the function double2long.

    Compatibility

    The decimal2long(decimal) function is available since CloverETL 3.0.0.

    Example 67.12. Usage of decimal2long

    The function decimal2long(9759223372036854775807.25D) fails with an error as the input decimal number is out of range of data type long.

    The function decimal2long(72036854775807.79D) returns 72036854775807.


    See also:  decimal2double, decimal2integer, round, roundHalfToEven

    double2integer

    integer double2integer(number arg);

    The double2integer() function converts a number argument to an integer.

    The conversion is narrowing and if a double value cannot be converted into integer (as the range of double data type does not cover all integer values), the function fails with an error.

    On the other hand, any integer can be converted into double without loss of precision.

    If the input is null, the function returns null.

    Compatibility

    The double2integer(double) function is available since CloverETL 3.0.0.

    Example 67.13. Usage of double2integer

    The function double2integer(352147483647.1) fails with an error as the input does not fit into integer data type.

    The function double2integer(25.757197) returns 25.


    See also:  round, roundHalfToEven

    double2long

    long double2long(number arg);

    The double2long() function converts a number argument to long.

    The conversion is narrowing, and if a double value cannot be converted into long (as the range of double data type does not cover all long values), the function fails with an error.

    On the other hand, any long can always be converted into double; however, the user should take into account that a loss of precision may occur.

    If the input argument is null, the function returns null.

    Compatibility

    The double2long(double) function is available since CloverETL 3.0.0.

    Example 67.14. Usage of double2long

    The function double2long(1.3759739E23) fails with an error.

    The function double2long(25.8579) returns 25.


    See also:  double2integer, round, roundHalfToEven

    hex2byte

    byte hex2byte(string arg);

    The hex2byte() function converts a string argument in hexadecimal representation to an array of bytes. Its counterpart is the byte2hex function.

    If the input is null, the function returns null.

    Compatibility

    The hex2byte(string) function is available since CloverETL 3.0.0.

    Example 67.15. Usage of hex2byte

    The function hex2byte("616263") returns bytes 0x61, 0x62, 0x63.


    See also:  byte2hex, str2byte

    json2xml

    string json2xml(string arg);

    The json2xml() function takes one string argument that is JSON formatted and converts it to an XML formatted string. Its counterpart is the function xml2json.

    Parsing of an input does not have to result in a valid XML structure. For example, if the root element of input JSON contained array, the XML document with more than one root element would be created.

    If the input is an invalid JSON formatted string or null, the function fails with an error.

    Compatibility

    The json2xml(string) function is available since CloverETL 3.1.0.

    Example 67.16. Usage of json2xml

    The function json2xml('{ "element1" : { "id" : "0", "date" : "2011-11-07" }, "element0" : { "id" : "1", "date" : "2012-10-12" }}') returns <element0><id>1</id><date>2012-10-12</date></element0><element1><id>0</id><date>2011-11-07</date></element1>.


    See also:  xml2json

    long2date

    date long2date(long arg);

    The long2date() function converts a long argument to a date.

    It adds the argument number of milliseconds to January 1, 1970, 00:00:00 GMT and returns the result as a date. Its counterpart is function date2long.

    If the input is null, the function returns null.

    Compatibility

    The long2date(long) function is available since CloverETL 3.0.0.

    Example 67.17. Usage of long2date

    The function long2date(1234567890000L) returns 2013-02-13 23:31:30.


    See also:  date2long

    long2integer

    integer long2integer(long arg);

    The long2integer() function converts a long argument to an integer value.

    The conversion is successful only if it is possible without any loss of information, otherwise the function fails with an error.

    On the other hand, any integer value can be converted into a long number without a loss of precision.

    If the input is null, the function returns null.

    Compatibility

    The long2integer(long) function is available since CloverETL 3.0.0.

    Example 67.18. Usage of long2integer

    The function long2integer(352147483647L) fails with an error.

    The function long2integer(25) returns 25.


    long2packDecimal

    byte long2packDecimal(long arg);

    The long2packDecimal() function converts a long data type argument to the representation of packed decimal number. It is the counterpart of the function packDecimal2long.

    If the input is null, the function returns null.

    Compatibility

    The long2packDecimal(long) function is available since CloverETL 3.0.0.

    Example 67.19. Usage of long2packDecimal

    The function long2packDecimal(256L) returns bytes %l. The result can be seen as 256C using hexadecimal notation.


    See also:  packDecimal2long

    md5

    byte md5(byte arg);

    byte md5(string arg);

    The md5() function calculates an MD5 hash value of the argument.

    If the input is null, the function fails with an error.

    If the input string may contain a non-ASCII character, it is recommended to convert the input string to an array of byte manually using the function str2byte to the bytes and than use the function md5.

    Compatibility

    The md5(byte) and md5(string) functions are available since CloverETL 3.0.0.

    Example 67.20. Usage of md5

    Use byte2hex() to convert MD5 hash from a byte array to a usual string representation of 32 hexadecimal digits. For example, byte2hex(md5sum("abcd")) returns e2fc714c4727ee9395f324cd2e7f331f.


    See also:  byte2hex, sha, sha256, str2byte

    num2bool

    boolean num2bool(<numeric type> arg);

    The num2bool() function converts a numeric type to boolean.

    The function takes one argument of any numeric data type (integer, long, number or decimal) and returns boolean false for 0 and true for any other value.

    If the input is null, the function returns null.

    Compatibility

    The num2bool(integer), num2bool(long), num2bool(double) and num2bool(decimal) functions are available since CloverETL 3.0.0.

    Example 67.21. Usage of num2bool

    The function num2bool(0) returns false.

    The function num2bool(3.1) returns true.


    See also:  bool2num

    num2str

    string num2str(<numeric type> arg);

    string num2str(integer | long | double arg, integer radix);

    string num2str(<numeric type> arg, string format);

    string num2str(<numeric type> arg, string format, string locale);

    The num2str() converts any numeric type to the string decimal representation.

    The function takes one argument of any numeric data type (integer, long, number, or decimal) and converts it to a string in decimal representation.

    If the input is null, the function returns null.

    The radix enables to convert the input number to a different radix-based numerical system, e.g. to the octal numerical system. For both integer and long data types, any integer number can be used as radix. For the data type double (number) only 10 or 16 can be used as radix.

    The format describes format of number. If the parameter is missing, the Numeric Format is used.

    If the locale parameter is missing, the locale has system value.

    Compatibility

    The num2str(integer), num2str(long), num2str(number), num2str(decimal), num2str(integer,integer), num2str(long,integer), num2str(number,integer), num2str(integer,string), num2str(long,string) num2str(double,string), num2str(decimal,string) num2str(integer,string,string), num2str(long,string,string), num2str(double,string,string) and num2str(decimal,string,string) functions are available since CloverETL 3.0.0.

    Example 67.22. Usage of num2str

    The function num2str(123456) returns 123456.

    The function num2str(123456L) returns 123456.

    The function num2str(123456.45) returns 123456.45.

    The function num2str(123456.67D) returns 123456.67

    The function num2str(123, 8) returns 173.

    The function num2str(123L, 8) returns 173

    The function num2str(123.75, 8) fails. Double as first argument works with base = 10 and base = 16 only.

    The function num2str(4.0, 16) returns 0x1.0p2.

    The function num2str(123456, "###,###") returns 123,456.

    The function num2str(123456L, "###,###") returns 123,456.

    The function num2str(123456.25, "###,###.#") returns 123,456.2.

    The function num2str(123456.75D "###,###.##") returns 123,456.75.

    The function num2str(123456, "###,###", "fr.FR") returns 123 456.

    The function num2str(123456L, "###,###", "fr.FR") returns 123 456.

    The function num2str(123456.75, "###,###.##", "fr.FR") returns 123 456,75.

    The function num2str(123456.25D, "###,###.##", "fr.FR") returns 123 456,25.


    See also:  str2double, toString

    packDecimal2long

    long packDecimal2long(byte arg);

    The packDecimal2long() function converts an array of bytes whose meaning is the packed decimal representation of a long number to a long number.

    If the input is null, the function returns null.

    Compatibility

    The packDecimal2long(byte) function is available since CloverETL 3.0.0.

    Example 67.23. Usage of packDecimal2long

    The function packDecimal2long(hex2byte("256C12")) returns 256.


    See also:  long2packDecimal

    sha

    byte sha(byte arg);

    byte sha(string arg);

    The sha() function calculates SHA-1 hash value of a given byte array or for a given string argument.

    If the input is null, the function fails with an error.

    If the input string may contain a non-ASCII character, it is recommended to convert the input string to an array of bytes manually using the function str2byte.

    Compatibility

    The sha(byte) and sha(string) functions are available since CloverETL 3.0.0.

    Example 67.24. Usage of sha

    Use byte2hex() to convert SHA-1 hash from a byte array to a string representation of 40 hexadecimal digits. For example byte2hex(sha("abcd")) returns 81fe8bfe87576c3ecb22426f8e57847382917acf.


    See also:  byte2hex, md5, sha256, str2byte

    sha256

    byte sha256(byte arg);

    byte sha256(string arg);

    The sha256() function calculates a SHA-256 hash value of a given array of bytes or of a given string argument.

    If the input is null, the function fails with an error.

    If the input string may contain a non-ASCII character, it is recommended to convert the input string to an array of bytes manually using the function str2byte.

    Compatibility

    The sha256(byte) and sha256(string) functions are available since CloverETL 3.4.x.

    Example 67.25. Usage of sha256

    Use the byte2hex() function to convert SHA-256 hash from a byte array to the usual string representation of 64 hexadecimal digits. For example byte2hex(sha256("abcd")) returns 88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589.


    See also:  byte2hex, md5, sha, str2byte

    str2bits

    byte str2bits(string arg);

    The str2bits() function converts a given string argument to an array of bytes.

    The string can contain only characters: "1" and "0". Each character "1" of a string is converted to the bit 1, each character "0" is converted to the bit 0. If the number of characters in the string is not an integral multiple of eight, the string is completed by "0" characters from the right. Then, the string is converted to an array of bytes as if the number of its characters were integral multiple of eight.

    The first character represents the lowest bit.

    If the input is null, the function returns null.

    If the input contains any other character, the function str2bits()fails.

    Compatibility

    The str2bits(string) function is available since CloverETL 3.0.0.

    The functionality of str2bits() has been changed in CloverETL 3.5.0. In the earlier versions, all characters not being 1 have been considered as 0. The function call str2bits("A010011001100110") is correct in CloverETL 3.4, but the same function call fails with an error in CloverETL 3.5.

    Example 67.26. Usage of str2bits

    The function str2bits("0010011001100110") returns bytes containing df.

    The function str2bits("0A10011001100110") fails with an error. See compatibility notice.


    See also:  bits2str

    str2bool

    boolean str2bool(string arg);

    The str2bool() function converts a given string argument to the corresponding boolean value.

    The string can be one of the following: "TRUE", "true", "T", "t", "YES", "yes", "Y", "y", "1", "FALSE", "false", "F", "f", "NO", "no", "N", "n", "0". The strings are converted to boolean true or boolean false.

    If the input is null, the function returns null.

    Compatibility

    The str2bool(string) function is available since CloverETL 3.0.0.

    Example 67.27. Usage of str2bool

    The function str2bool("true") returns true.

    The function str2bool("True") fails. The string True (with uppercase T and lowercase rest of the letters) is not allowed as a value.

    The function str2bool("NO") returns false.


    See also:  str2bits, str2bool, str2date, str2decimal, str2double, str2integer, str2long

    str2byte

    byte str2byte(string payload, string charset );

    The str2byte() function converts a string payload to an array of bytes using a given charset encoder.

    If the charset is null, the function fails with an error. If the payload is null, the function returns null.

    Compatibility

    The str2byte(string,string) function is available since CloverETL 3.2.x.

    Example 67.28. Usage of str2byte

    The function str2byte("grep", "utf-8") returns bytes 0x67, 0x72, 0x65 and 0x70.

    The function str2byte("voilà", "utf-8") returns bytes 0x76, 0x6f, 0x69, 0x6c, c3 and a0.


    See also:  byte2str, hex2byte

    str2date

    date str2date(string input, string pattern);

    date str2date(string input, string pattern, boolean strict);

    date str2date(string input, string pattern, string locale);

    date str2date(string input, string pattern, string locale, boolean strict);

    date str2date(string input, string pattern, string locale, string timeZone);

    date str2date(string input, string pattern, string locale, string timeZone, boolean strict);

    The str2date() function converts the input to the date data type using the specified pattern, locale and timeZone.

    The input must correspond with the pattern. Otherwise the function fails. If the input is null, the function returns null.

    If the pattern is null or an empty string, the default date format is used.

    If the locale is null or an empty string, the respective default value is used instead.

    If the timeZone is null or an empty string, the respective default value is used instead.

    If strict is true, date format is checked using a conversion from string to date, conversion from date to string and subsequent comparison of an input string and result string. If the input string and result string differ, the function fails. This way you can enforce required number of digits in date.

    If strict is null or the function does not have the argument strict, it works in the same way as if it was set to false - the format is not checked in the strict way.

    Compatibility

    The str2date(string,string) and str2date(string,string,string) functions are available since CloverETL 3.0.0.

    The str2date(string, string, boolean), str2date(string, string, string, boolean) and str2date(string, string, string, string, boolean) functions are available since CloverETL 4.1.0.

    Example 67.29. Usage of str2date

    The function str2date("12.6.2008", "dd.MM.yyyy") returns the date 2008-06-12 in a local time zone.

    The function str2date("12.6.2008", "dd.MM.yyyy", "cs.CZ") returns the date 2008-06-12 in a local time zone.

    The function str2date("12.6.2008 13:55:06", "dd.MM.yyyy HH:mm:ss", "cs.CZ", "GMT+5") returns the date 2008-06-12 13:55:06 in the "GMT+5" time zone.

    The function str2date("15-Dezember-2010","dd-MMMM-yyyy", "de.DE") returns 15 December 2010 in a local time zone, interpreting the month name using the German locale.

    The function str2date("6.007.2015", "dd.MM.yyyy", false) returns 6 July 2015 whereas the function str2date("6.007.2015", "dd.MM.yyyy", true) fails.

    ISO-8601

    The function str2date("2015-10-04", "iso-8601:yyyy-MM-dd") returns 2015-10-04 in a local time zone.

    The function str2date("2015-10-04", "iso-8601:date") returns 2015-10-04 in a local time zone.

    The function str2date("2015-10-05T06:07:02.123+00:00", "iso-8601:yyyy-MM-dd'T'H:m:sZZZ") returns 2015-10-05 06:07:02.123 in the time zone +00:00.

    The function str2date("2015-10-05T06:07:02.123+00:00", "iso-8601:dateTime") returns 2015-10-05 06:07:02.123 in the time zone +00:00.

    The function str2date("2015-10-05T06:07:02.234Z", "iso-8601:yyyy-MM-dd'T'H:m:sZZZ") returns 2015-10-05 06:07:02.234 in the time zone +00.00.

    Joda

    The function str2date("2015-06-15 00:00:10 America/New_York","joda:yyyy-MM-dd HH:mm:ss ZZZ") returns 2015-06-15 00:00:10 in time zone America/New_York that corresponds to 2015-06-15 04:00:10 in UTC.


    See also:  date2str, isDate

    str2decimal

    decimal str2decimal(string arg);

    decimal str2decimal(string arg, string format);

    decimal str2decimal(string arg, string format, string locale);

    The str2decimal() function converts a given string argument to a decimal value.

    The conversion can be determined by the format specified as the second argument and the locale specified as the third argument.

    The arg is a numeric value to be converted to the decimal. If the argument is null, the function returns null.

    The format determines the data conversion. See Numeric Format.

    The locale parameter is described in Locale. If the function is called without the locale parameter, the default locale is used.

    Compatibility

    The str2decimal(string), str2decimal(string,string) and str2decimal(string,string,string) functions are available since CloverETL 3.0.0.

    Example 67.30. Usage of str2decimal

    The function str2decimal("23") returns 23.

    The function str2decimal("23.45") returns 23.45.

    The function str2decimal("123.456789") returns 123.45.

    The function str2decimal("2.147483648e9") returns 2147483648.00.

    The function str2decimal("123,456.78", "###,###.##") returns 123456.78.

    The function str2decimal("123 456,78", "###,###.##", "fr.FR") returns 123456.78. There should be a hard space (character 160) between 3 and 4.


    See also:  str2double, str2integer, str2long, toString

    str2double

    number str2double(string arg);

    number str2double(string arg, string format);

    number str2double(string arg, string format, string locale);

    The str2double() function converts a given string argument to the corresponding double value. The conversion can be determined by a format specified as the second argument and a locale specified as the third argument.

    The arg is string to be converted to double. If the argument is null, the function returns null.

    The format is described in Data Formats.

    The locale parameter is described in Locale. If the function is called without the locale parameter, the default locale is used.

    Compatibility

    The str2double(string), str2double(string,string) and str2double(string,string,string) functions are available since CloverETL 3.0.0.

    Example 67.31. Usage of str2double

    The function str2double("123.25") returns 123.25.

    The function str2double("123,456", "###,###") returns 123456.0

    The function str2double("123 456,25", "###,###.##", "fr.FR"") returns 123456.25. There must must be a hard space between 3 and 4.


    See also:  num2str, toString

    str2integer

    integer str2integer(string arg);

    integer str2integer(string arg, integer radix);

    integer str2integer(string arg, string format);

    integer str2integer(string arg, string format, string locale);

    The str2integer() function converts a given string argument to the corresponding integer value. The conversion can be determined by a numeral system, format or locale.

    The parameter arg is a numeric value to be converted to integer. If the argument is null, the function returns null.

    The parameter radix enables to convert a given string argument to integer using specified radix based numeric system representation.

    The format is described in Numeric Format.

    The locale is described in Locale.

    Compatibility

    The str2integer(string), str2integer(string,string), str2integer(string,string,string) and str2integer(string,integer) functions are available since CloverETL 3.0.0.

    Example 67.32. Usage of str2integer

    The function str2integer("123") returns 123.

    The function str2integer("123.45") fails as argument in not an integer.

    The function str2integer("12345678901") fails as argument does not fit into the integer data type. The value is too big.

    The function str2integer("101", 8) returns 65. Value 101 in the octal numeral system is same as 65 in the decimal numeral system.

    The function str2integer("123,456", "###,###") returns 123456.

    The function str2integer("123.456", "###,###", "de.DE") returns 123456.

    The function str2integer("123 456", "###,###", "fr.FR") returns 123456. There must be a hard space between digits 3 and 4. See Space as group separator.


    See also:  toString

    str2long

    long str2long(string arg);

    long str2long(string arg, integer radix);

    long str2long(string arg, string format);

    long str2long(string arg, string format, string locale);

    The str2long() function converts a given string argument to a long value.

    If the value is expressed in the radix based numeric system, the representation is specified by the second argument.

    The conversion can be affected using a format specified as the second argument and the system locale.

    The arg is the value to be converted to long. If the argument is null, the function returns null.

    The radix is radix of numeral system.

    The format is a format of the number to be converted. For details, see Numeric Format.

    The locale is described in Locale.

    Compatibility

    The str2long(string), str2long(string,string), str2long(string,string,string) and str2long(string,integer) functions are available since CloverETL 3.0.0.

    Example 67.33. Usage of str2long

    The function str2long("123456789012") return 123456789012

    The function str2long("123.45") fails as argument is not a long number.

    The function str2long("101", 8) returns 65.

    The function str2long("123,456,789,012", "###.###") returns 123456789012.

    The function str2long("123.456.789.012", "###,###", "de.DE") returns 123456789012


    See also:  toString

    toString

    string toString(<numeric|boolean|list|map type> arg);

    The toString() function converts a given argument to its string representation. It accepts any numeric data type, list of any data type, as well as map of any data types.

    If the input arg is null, the function returns string "null".

    Compatibility

    The toString(int|long|double|decimal|map|list) function is available since CloverETL 3.0.0.

    The toString(boolean) function is available since CloverETL 4.1.0.

    Example 67.34. Usage of toString

    Function toString(34) returns 34.

    Function toString(1234567890123L) returns 1234567890123.

    Function toString(1234.567) returns 1234.567.

    Function toString(1234.567D) returns 1234.567.

    Function toString(true) returns true.


    See also:  str2decimal, str2double, str2integer, str2long

    xml2json

    string xml2json(string arg);

    The xml2json() function converts a string XML formatted argument to a JSON formatted string. Its counterpart is the function json2xml.

    If the input is null, the function fails with an error.

    Compatibility

    The xml2json(string) function is available since CloverETL 3.1.0.

    Example 67.35. Usage of xml2json

    The function xml2json('<element0><id>1</id><date>2012-10-12</date></element0><element1><id>0</id><date>2011-11-07</date></element1>') returns { "element1" : { "id" : "0", "date" : "2011-11-07" }, "element0" : { "id" : "1", "date" : "2012-10-12" }}.


    See also:  json2xml