Casting numbers, dates, and booleans with Expression Language

Modified on Thu, 11 Dec, 2025 at 8:23 PM

Summary

Expression Language treats attributes as strings unless explicitly cast. Many failures happen because numeric or date comparisons require casting.

Symptom

  • Numeric comparisons fail

  • Date comparisons are incorrect

  • Boolean logic always evaluates false

  • Routing is inconsistent

Root Cause

  • EL treats all attributes as strings by default

  • “10” > “2” is true as a string but false as a number

  • Dates must be parsed using EL functions

  • Boolean attributes stored as strings require conversion

How to Fix It

Cast numbers

${field:toNumber()}

Cast booleans

${flag:toBoolean()}

Parse dates

${dateString:toDate():format('yyyy-MM-dd')}

Prevention

  • Always cast before comparing

  • Standardize date formats early

  • Avoid storing numbers as mixed-format strings

Related Articles

  • Expression Language reference

  • Debugging routing logic

  • Using toDate, toNumber, and toBoolean

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article