Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumberFormatException for ISO dates as a variable value #319

Closed
chkal opened this issue Sep 30, 2022 · 2 comments
Closed

NumberFormatException for ISO dates as a variable value #319

chkal opened this issue Sep 30, 2022 · 2 comments
Labels

Comments

@chkal
Copy link

chkal commented Sep 30, 2022

If you have code like this:

new Expression( "23" )
  .with( "someString", "2022-01-02" )
  .eval();

The following exception is thrown:

java.lang.NumberFormatException
	at java.math.BigDecimal.<init>(BigDecimal.java:497)
	at java.math.BigDecimal.<init>(BigDecimal.java:827)
	at com.udojava.evalex.Expression.setVariable(Expression.java:1804)
	at com.udojava.evalex.Expression.with(Expression.java:1923)
	at com.udojava.evalex.TestVariables.testIsoDateInString(TestVariables.java:119)

The issue seems to be that Expression.isNumber() returns true and creating a BigDecimal from the string fails.

Please note that this issue occurs on the current 2.x branch.

chkal added a commit to chkal/EvalEx that referenced this issue Sep 30, 2022
@chkal
Copy link
Author

chkal commented Sep 30, 2022

I just created a PR for a unit test that reproduces this issue: #320

@uklimaschewski
Copy link
Collaborator

Thank you, but I think I will not fix this on the old 2.x branch. Anyone who needs to add strings to expressions should upgrade to version 3. It has full string support and will probably also have date and time support in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants