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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -