java - Is there a method that parses int or returns 0 if unable to do so? -
i having write in different places , projects.
int appointmentid = integer.parseint(stringutils.isnotempty(request.getparameter ("appointmentid")) ? request.getparameter("appointmentid"): "0");
is there common class returns parsed int or 0 or specify default return value?
apache commons' numberutils.toint()
returns 0 if conversion fails.
(and lets specify default value on conversion failure.)
Comments
Post a Comment