function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Uday KUday K 

can anyone Please give a resolution for error : System.TypeException: Invalid date: 12/null/null.

Hi Everyone,

I have taken Month, Day, Year as three different strings and assigned it to a new variable DateOfBirth. Then i passed it into the date of birth field in the object, its working fine. But when i am trying to test my test class. Its giving the following error if i pass the day, month, year individually also.

System.TypeException: Invalid date: 12/null/null.

Awaiting  for Early response. Its urgent Please.

Thanks,
Uday
bob_buzzardbob_buzzard

Can you post your code.

Uday KUday K

Hi bob, Please check the code

@isTest
public class Test_CLS_ProspectDetails {
static testMethod void CLS_ProspectDetails() {
Affilate__c testAff = new Affilate__c ();    
testAff.user_name__c = 'testAccount';
testAff.Password__c = 'Password123';
testAff.Name='Affname';
insert testAff ;
prospect__c pros= new prospect__c();
pros.affilate__c=testaff.id;
pros.Name='Prospect1';
pros.SSN__c = '333';
pros.Telephone__c = '9620388646';
pros.Cell_Phone__c = '9620388646';
pros.Work_Phone__c = '9620388646';
insert pros;
Credit_Calculator__c cal=new Credit_Calculator__c();
cal.prospect__c=pros.id;
insert cal;
ApexPages.currentPage().getParameters().put('Flag','1');
ApexPages.currentPage().getParameters().put('vID',testaff.id);
ApexPages.currentPage().getParameters().put('pID',pros.id);
ApexPages.currentPage().getParameters().put('lookup',pros.id);
ApexPages.currentPage().getParameters().put('prosID',pros.id);
ApexPages.StandardController controller = new ApexPages.StandardController(new prospect__c());
CLS_ProspectDetails objpros= new CLS_ProspectDetails(controller);
objpros.Day = '3';
objpros.Year = '1986';
Integer f=integer.valueof(objpros.Flag);
f=1;
objpros.ProsSave();
f=2;
objpros.ProsSave();
Ineger i=integer.valueof(objpros.Flag);
if(i == 1) {
    objpros.Month = 'Jan';
   if(objpros.Month == 'Jan') {
        objpros.Month = '1';
        objpros.Day = '16';
        objpros.Year = '1986';
        objpros.Dateofbirth = objpros.Month + '/' + objpros.Day + '/' + objpros.Year ;
        pros.Date_Of_Birth__c = Date.parse(objpros.Dateofbirth);
        }else { system.debug('***eeeeee***'); }
        objpros.submit(); } else {
        objpros.Month = '2';
        objpros.Day = '16';
        objpros.Year = '1986';
        objpros.Dateofbirth = objpros.Month +'/'+ objpros.Day + '/' + objpros.Year ;
        pros.Date_Of_Birth__c = Date.parse(objpros.Dateofbirth);
        objpros.submit();
        }
        objpros.doDisable();
        objpros.Back();
        objpros.EditProsp();
        objpros.ProsContract();
        objpros.Calc();
        update cal;
        objpros.attach();
        objpros.Cancel1();
        objpros.uploadDocs();
        Integer l=integer.valueof(objpros.currentTab);
        l = 1;
        objpros.next();
        l = 2;
        objpros.previous();
        objpros.Summons();
     }
}

Thanks,

Uday

bob_buzzardbob_buzzard

Do you get the exception from the test class, i.e. when constructing the test data, or is it from a controller method that you execute?

Uday KUday K

Hi bob,

 

I am getting from the test data. i.e., when passing the date in the test class.

 

Thanks,

Uday

bob_buzzardbob_buzzard

I can't see anything obvious - which line number is the error occurring on?