I have the following code:
SimpleDateFormat formatDDMMYYY = new SimpleDateFormat("dd/MM/yyyy");
Calendar quotationDay = Calendar.getInstance();
try {
quotationDay.setTime(formatDDMMYYY.parse("06/13/2015"));
} catch (ParseException e) {
throw new RuntimeException("Quotation date is in incorrect format.");
}
The date "06/13/2015" is incorrect, as there is no 13th month. Java automatically parses it to the next month, in 2016. Is there any way I can prevent this from happening and throw an exception?
You need to set
Check the spec