A utility library with primitive types tryParse methods in java? -


in java when parsing date or int or primitive type string, needs done in try catch because parseexception occur. nice if there method tryparse did not throw exception rather returns true or false if string or not parsed. there few examples online describe writing utility function parsing int. believe necessary few more types: int, long, date, etc...because such common problem wondering there utility library has these tryparse methods primitive types?

apache commons lang has classes tasks.


numberutils has methods:

isnumber - checks whether string valid java number.

isparsable - checks whether given string parsable number.


dateutils contains method parsedate can used implement isparsable method dates, according needs.

you can use these classes implement own simple framework avoid parseexceptions in code.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -