Type Conversion Functions
This section describes functions that are used to perform conversions between different types.
The following functions for Type Conversion described here are:
baToBigInt
Converts a bytearray to a big integer (two complement).
void baToBigInt (bigint bigintVar, bytearray baValue)
Parameter | Description |
---|---|
| Bigint variable to set |
| Bytearray value |
Returns | Nothing |
baToHexString
Converts a bytearray to a string containing the hexadecimal values.
string baToHexString(bytearray baValue)
Parameter | Description |
---|---|
| Bytearray value |
Returns | A hexadecimal string |
baToStr
Converts a bytearray to a string.
string baToStr (bytearray array, string charEncoding) //Optional
Parameter | Description |
---|---|
| The bytearray to convert |
| The character encoding to use. If no encoding is specified, ISO-8859-1 (Latin 1) is used. If you specify character encoding, it must match the character encoding included in the standard charsets found in https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/charset/Charset.html or the extended charset of the target Java implementation. If you specify a character encoding that cannot be found, a compilation error occurs. |
Returns | The result string |
dateToString
Converts a date to a string and assigns the result to a string variable (or field). Returns true if the conversion succeeded. The only time the conversion can fail, is if the date is null or the format is invalid.
boolean dateToString (string stringVar, date dateValue, string format) //optional
Parameter | Description |
---|---|
| String identifier to set. |
| The date value. |
| If no format string is specified, the default system format is used as specified in the property The date formatting is based on standard Java syntax. For further information, see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/text/SimpleDateFormat.html. |
Returns |
|
strToBA
Converts a string to a bytearray and assigns the result to a bytearray variable (or field).
void strToBA (bytearray array, string stringValue, string charEncoding) //Optional
Parameter | Description |
---|---|
| The resulting bytearray |
| The string value |
| The character encoding to use. If no encoding is specified, ISO-8859-1 (Latin 1) is used. If you specify character encoding, it must match the character encoding included in the standard charsets found in https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/charset/Charset.html or the extended charset of the target Java implementation. If you specify a character encoding that cannot be found, a compilation error occurs. |
Returns | Nothing |
strToBigInt
Converts a string to a big integer. If the conversion was successful true
is returned.
If one of the keywords dec
or hex
are specified, the string is assumed to be decimal or hexadecimal respectively. Decimal is the default.
boolean strToBigInt (bigint bigintVar, string stringValue, dec|hex) //Optional
Parameter | Description |
---|---|
| Big integer variable to set |
| String value |
Returns |
|
strToDate
Converts a string to a date and assigns the result to a date variable (or field). Returns true
if the conversion succeeded.
You can enable lenient interpretation of the date/time in the string to be converted by setting the Cell property mz.drdate.lenient
 to true in the cell.conf
. With lenient interpretation, a date such as "January 32, 2016" will be treated as being equivalent to the 31nd day after January 1, 2016. With strict (non-lenient) interpretation, an invalid date will cause the function to leave the submitted date variable unchanged. The default value of mz.drdate.lenient
 is false
.
boolean strToDate (date dateVar, string stringValue, string format, //Optional string timeZone) //Optional
Parameter | Description |
---|---|
| Date identifier to set |
| Date value |
| If no format string is specified, the default system format is used as specified in The date formatting is based on standard Java syntax. For further information, see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/text/SimpleDateFormat.html. Note! Even though the syntax conforms to You can enable date format handling based on the $ mzsh topo set topo://container:<container>/pico:<pico name>/val:config.properties.mz.use.drdateformat false
Note! Unlike If this is an issue, it can be solved by setting the locale to US_en in the JVM arguments of the relevant EC. $ mzsh topo set topo://container:<container>/pico:<pico name>/obj:config.jvmargs \ 'usercountry: ["-Duser.country=US"] userlanguage: ["-Duser.language=en"]' |
| An optional string stating the time zone to set. It is recommended that you specify the time zone id using the long format, e g "America/St_Johns". It is possible to also use the abbreviated format, e g "PST". However, this can lead to ambiguous results and should be avoided. If an invalid time zone format is entered, no error is returned. Instead, the time zone is automatically set to "GMT". If the time zone is specified in the |
Returns |
|
strToDouble
Converts a decimal string to a double and assigns the result to a double variable (or field). Returns true
if the conversion succeeded.
boolean strToDouble (double doubleVar, string stringValue)
Parameter | Description |
---|---|
| Double identifier to set. |
| String value. |
Returns |
|
strToFloat
Converts a decimal string to a float and assigns the result to a float variable (or field). Returns true
if the conversion succeeded.
boolean strToFloat (float floatVar, string stringValue)
Parameter | Description |
---|---|
| Float identifier to set |
| String value |
Returns |
|
strToInt
Converts a decimal or hexadecimal string to an integer and assigns the result to an integer variable (or field). Returns true
if the conversion succeeded.
If one of the keywords dec
or hex
are specified, the string is assumed to be decimal or hexadecimal respectively. Decimal is the default.
boolean strToInt (int intVar, string stringValue, dec|hex) //Optional
Parameter | Description |
---|---|
| Integer identifier to set. |
| String value. |
Returns |
|
Example - Using strToInt
Provided that the field CallTime
is a string containing a hexadecimal string, it converts its content to an integer.
int a; int b; strToInt( a, CallTime, hex ); strToInt( b, "12345" ); /* dec is default */
strToLong
Converts a decimal or hexadecimal string to a long and assigns the result to an long variable (or field). Returns true
if the conversion succeeded.
If one of the keywords dec
or hex
are specified, the string is assumed to be decimal or hexadecimal respectively. Decimal is the default.
boolean strToLong (long longVar, string stringValue, dec|hex) //Optional
Parameter | Description |
---|---|
| Long identifier to set |
| String value |
Returns |
|
strToBigDec
Converts a decimal or hexadecimal string to a BigDecimal and assigns the result to a BigDecimal variable (or field). Returns true if the conversion succeeded.
boolean strToBigDec (bigdec bigdecVar, string stringValue)
Parameter | Description |
---|---|
| BigDecimal identifier to set |
| String value |
Returns |
|
udrToString
Converts a UDR to a string. Each UDR will be preceded with the internal class name, and each of its field will be preceded with the field name.
string udrToString(drudr myUDR)
Parameter | Description |
---|---|
| The UDR to convert |
Returns | A string containing the UDR fields. The output will be in the following format: Field values for: <internal UDR reference> field1: <value> field2: <value> |