Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section describes functions that are used to perform conversions between different types.


baToBigInt

Converts a bytearray to a big integer (two complement).

...

ParameterDescription

bigintVar

Bigint variable to set

baValue

Bytearray value

Returns

Nothing


baToHexString

Converts a bytearray to a string containing the hexadecimal values.

...

ParameterDescription

baValue

Bytearray value

Returns

A hexadecimal string


baToStr

Converts a bytearray to a string.

...

ParameterDescription

array

The bytearray to convert

charEncoding

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/817/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.

...

ParameterDescription

stringVar

String identifier to set.

dateValue

The date value.

format

If no format string is specified, the default system format is used as specified in the property mz.server.dateformat. For further information about this property, see /wiki/spaces/MD82/pages/3778734 in the /wiki/spaces/MD82/pages/3778529see Cell in the System Administrator's Guide.

The date formatting is based on standard Java syntax. For further information, see httphttps://docs.oracle.com/en/java/javase/817/docs/api/java.base/java/text/SimpleDateFormat.html.

Returns

true or false.


strToBA

Converts a string to a bytearray and assigns the result to a bytearray variable (or field).

...

ParameterDescription

array

The resulting bytearray

stringValue

The string value

charEncoding

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/817/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.

...

ParameterDescription

bigintVar

Big integer variable to set

stringValue

String value

Returns

true or false


strToDate

Converts a string to a date and assigns the result to a date variable (or field). Returns true if the conversion succeeded.

...

ParameterDescription

dateVar

Date identifier to set

stringValue

Date value

format

If no format string is specified, the default system format is used as specified in $MZ_HOME/common/config/cell/default/master/cell.conf, the mz.server.dateformat property.

The date formatting is based on standard Java syntax. For further information, see httphttps://docs.oracle.com/en/java/javase/817/docs/api/java.base/java/text/SimpleDateFormat.html.

Note
titleNote!

Even though the syntax conforms to SimpleDateFormat, it is not directly based on this class.

You can enable date format handling based on the SimpleDateFormat class in the installed Java version by setting the Execution Context property mz.use.drdateformat to false. This enables use of additional patterns that are available in the installed Java version.

Code Block
$ mzsh topo set topo://container:<container>/pico:<pico name>/val:config.properties.mz.use.drdateformat false



When mz.use.drdateformat is set to true (default), the function does not apply the timezone offset at conversion. The timezone can be specified but the date is not modified.


Note
titleNote!

Unlike SimpleDateFormat the strToDate function does not accept the Locale parameter and uses the default JVM locale instead, which may result in parsing errors.

If this is an issue, it can be solved by setting the locale to US_en in the JVM arguments of the relevant EC/ECSA.

Code Block
$ mzsh topo set topo://container:<container>/pico:<pico name>/obj:config.jvmargs \
'usercountry: ["-Duser.country=US"]
userlanguage: ["-Duser.language=en"]'



timeZone

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 stringValue , it overrides the timeZone parameter.

Returns

true or false.


strToDouble

Converts a decimal string to a double and assigns the result to a double variable (or field). Returns true if the conversion succeeded.

...

ParameterDescription

doubleVar

Double identifier to set.

stringValue

String value.

Returns

true or false.


strToFloat

Converts a decimal string to a float and assigns the result to a float variable (or field). Returns true if the conversion succeeded.

...

ParameterDescription

floatVar

Float identifier to set

stringValue

String value

Returns

true or false


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.

...


ParameterDescription

intVar

Integer identifier to set.

stringValue

String value.

Returns

true or false.


Info
titleExample - Using strToInt

Provided that the field CallTime is a string containing a hexadecimal string, it converts its content to an integer.

Code Block
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.

...

ParameterDescription

longVar

Long identifier to set

stringValue

String value

Returns

true or false


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.

Code Block
boolean strToBigDec
 (bigdec bigdecVar,
 string stringValue)


ParameterDescription

bigdecVar

BigDecimal identifier to set

stringValue

String value

Returns

true or false

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.

...