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

Specify NumberUtils.parseNumber() trim behavior in the javadoc [SPR-9523] #14157

Closed
spring-projects-issues opened this issue Jun 20, 2012 · 3 comments
Assignees
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jun 20, 2012

Penny Rohr opened SPR-9523 and commented

Prior to performing conversion, NumberUtils is removing all whitespace from input string instead of removing only leading/trailing whitespace. This results in incorrect conversions instead of expected exceptions. As an example, calling NumberUtils.parseNumber("2 3", Double.class) will result in a new Double("23").


Affects: 3.0.5, 3.1.1

Referenced from: commits 78a6429

1 votes, 3 watchers

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 6, 2012

Chris Beams commented

What would you expect to NumberUtils.parseNumber("2 3", Double.class) to return?

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 6, 2012

Penny Rohr commented

I would expect this to generate some kind of exception. "2 3" is not a valid number format.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 28, 2018

Sébastien Deleuze commented

I think the current behavior is correct, it is probably used in various application where you input credit card number or other use cases like that where in between space characters are usual, so I turn this issue into a Javadoc improvement one.

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

Successfully merging a pull request may close this issue.

None yet
2 participants