🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators strToInt
This page was created by Peter on 2019-11-22. Last edited by Wikiadmin on 2026-07-29.

strToInt converts text that represents an integer into an Integer value for use in OCL expressions. Use it when a value is available as a string but the next part of your expression requires an Integer.

Result

strToInt returns an Integer whose value is equal to the string value of self.

If self does not represent an integer, the result is invalid. Handle or prevent non-integer input before relying on the converted value in a calculation, comparison, or other expression.

Examples

The following examples describe the conversion result:

String value Result
A string representing the integer 42 The Integer 42
A string that does not represent an integer invalid

For example, use strToInt when a string-valued field contains an integer that you need to compare with another Integer value. Do not use the result as though it were a valid Integer when the source string may contain non-integer text.

Related conversion operators

strToInt and toInteger both describe conversion to an Integer. Use the operator that matches the type and expression form you are working with.

For conversions to date and date-time values, see strToDate and strToDateTime. For other parsing scenarios, see Parse.

See also