Number format exception while parsing the date to long

The reason for the NumberFormatException is cause you are trying to parseLong a String that is not a valid long representation: “2/15/2015”

To parse the date string you’ve come up with correctly use this code:

SimpleDateFormat format = new SimpleDateFormat("M/dd/yyyy");
Date date = format.parse(month + 1 + "" + day_of_month + "" + year);

Leave a Comment