You need to sign in to do that
Don't have an account?
Christopher Pezza
Convert String Date to Date in Apex Class to insert to Object Field Type Date
public void SaveTheNewWebinars(){ system.debug('**It Worked**'); Webinar_nRichment_Attendees__c webinars = new Webinar_nRichment_Attendees__c(); Date newestwebDate = Date.parse(newwebDate); String newestwebType = newwebType; webinars.Name__c = newwebName; webinars.Activity_Date__c = newestwebDate; if (newestwebType == 'Webinar') { webinars.Webinar_Attendees__c = newwebAttendees; } else { webinars.nRichment_Attendees__c = newwebAttendees; } insert(webinars); }Ho do i convert "newwebDate" from 12/20/2014 to a Date format to insert to a object with a field with date type?
All Answers
http://www.salesforce.com/us/developer/docs/dbcom_apex230/Content/apex_methods_system_date.htm
if newwebDate is a string of value '12/20/2014' and you are in the correct (US?) localle, newestWebDate should be a valid date field to pass into your object.
Does the above code not work for you though? If not, what errors are you getting? Are you sure the field is a Date, and not a DateTime?