Jetant un personnalisé NumberFormatException en Java

Je suis en train de lancer mon propre NumberFormatException quand convrting une Chaîne mois dans un Entier. Vous ne savez pas comment lancer l'exception. Toute aide serait appréciée. Ai-je besoin d'ajouter un try-catch avant la présente partie du code? J'en ai déjà un dans une autre partie de mon code.

//sets the month as a string
mm = date.substring(0, (date.indexOf("/")));
//sets the day as a string
dd = date.substring((date.indexOf("/")) + 1, (date.lastIndexOf("/")));
//sets the year as a string
yyyy= date.substring((date.lastIndexOf("/"))+1, (date.length()));
//converts the month to an integer
intmm = Integer.parseInt(mm);
/*throw new NumberFormatException("The month entered, " + mm+ is invalid.");*/
//converts the day to an integer
intdd = Integer.parseInt(dd);
/* throw new NumberFormatException("The day entered, " + dd + " is invalid.");*/
//converts the year to an integer
intyyyy = Integer.parseInt(yyyy);
/*throw new NumberFormatException("The yearentered, " + yyyy + " is invalid.");*/
Ce qui se passe avec le code que vous avez dit?
Je reçois un inaccessible de tresorerie pour le code après le lancer.
J'ai pris la remise des déclarations et ajouté ma propre Chaîne à l'endroit où j'ai été la capture de l'exception plus haut dans mon code.

OriginalL'auteur NYC Canuck | 2011-11-08