Though I am not sure of the exact error that you are facing, but I think the below pointers will help you;
- customdate__c is of type Date
If this date field you have included in you VF page like
<apex:inputField value="account.customdate__c"/>
then, when you click on any commandbutton or commandlink, it get validate itself before your action method is called and the error will be shown. You cannot handle it in server side because this value will never reach server side.
2.
customdate__c is of type
Text
Then you can try
if(!String.isBlank(this.account.customdate__c)){
try {
Date.parse(this.account.customdate__c);
} catch (System.TypeException te) {
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Not a valid date.');
ApexPages.addMessage(myMsg);
}
} else {
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Date value cannot be null.');
ApexPages.addMessage(myMsg);
}
From the code above I do think you are using it in a ApexController. In case of trigger use record.addError() in place of apexMessages.