Hello Rob, Rob Tompkins <chtom...@gmail.com> schrieb am Do., 28. Juli 2016 um 14:23 Uhr:
> In short, I’m trying to generalize LANG-1060, LANG-1040, LANG-1038, and > LANG-992 with a single issue that actually hits all the bases here with > NumberUtils.isNumber. > > Bug (1): > > System.out.println(lang.math.NumberUtils.isNumber(“+2”)); ----> > false > > while > > System.out.println(lang.math.NumberUtils.createNumber(“+2)); ----> > 2 > > Bug (2): > > > System.out.println(lang.math.NumberUtils.isNumber(“01.5”)); ----> > false > > while > > System.out.println(lang.math.NumberUtils.createNumber(“01.5)); > ----> 1.5. > > > > It seems to me that we could externalize a considerable amount of the code > underlying the two methods into shared methods, as it seems like all the > validations in createNumber that predicate object creation should be > directly used in isNumber. I would love to hear folks’ thoughts. > I think it is important to pay close attention to the JavaDocs in this case. NumberUtils.isNumber : Checks whether the String a valid Java number. This has nothing to do with createNumber: NumberUtils.createNumber: Turns a string value into a java.lang.Number What you're probably looking for is: NumberUtils.isParsebale: Checks whether the given String is a parsable number. The difference is, that isNumber tells you, whether putting the given String into Java code woul compile, while isParseble stells you whether a call to createNumber will be successful. Regards, Benedikt > Cheers, > -Rob > > > >