I have written a test class in which I just want to set one date field. How can I achieve this? I am not able to set the value using the following code:
Account acc=new Account(); acc.effectiveDate__c= '09.12.2016';
Answer
You can do this using Apex’ Date class:
acc.effectiveDate__c = Date.newInstance(2016, 12, 9);
For more information check out the documentation: Apex Developer Guide – Date Class
Attribution
Source : Link , Question Author : uma451 , Answer Author : Markus Dang – formerly Slabina