+ Start a Discussion
vijendahr kvijendahr k 

date format validaion in apex trigger

hello all, 

 i want to validate date format by using apex in trigger. currnly date is comming from java callout, need to check they are sendig valid date or not before save record in salesforce.

Thanks Advance
 
 
Amit Chaudhary 8Amit Chaudhary 8
Please post your code so that we can help you
Guru Vemuru 1Guru Vemuru 1
Send us your code
 
vijendahr kvijendahr k
StartTime__c  is comming as string, now i need to check that, StartTime__c is  valid as proper datetime format also. help me on this.

date format should is : 2015-15-10 12:03:00.000 i am getting it as string.
if date format comes except any other format date condition must fail.

condition 1:
    if(clb.StartTime__c == null || check  date format or not )
{
   msg ='Start Time is unknown or out-of-range value'
}

condition 2: StartTime__c  and EndTime__c both are in string format

need to check now 

if(clb.StartTime__c <clb.EndTime__c ) // need to covert EndTime__c and endTime__c , verify condition in datetime format.

 msg= starttime greter than end time 


how can achive these 2 contitions 


Thanks advance :)