I am getting:
System.TypeException: Invalid date: 30/06/2016
exception as I try to enter future dates in my date of birth inputtext. To validate this I have put below code:
Date dt=Date.parse(this.bufferdate);
if (dt > Date.Today()) {
system.debug('today date'+Date.Today());
isValid = false;
isFutureBirthDateError=true;
}
Here bufferdate is string and value of DateOfBirth.
Please help me with fix. thanks in advance
Best Answer
parse() returns the formatted string depends on the user locale. Check your locale in user record and its date format here Supported locales
From your message noticed its not accepting format(dd/mm/yyyy) 30/06/2016, so you may need to change the format of bufferdate string as per your locale like (mm/dd/yyyy or dd-mm-yyyy..) or need to change the locale in user record.