You need to sign in to do that
Don't have an account?

test case help
i have written this code in controller to appent date time
string parentID ; string year = String.valueOf(userInputAppointment.Appt_Date__c.year()); string month = String.valueOf(userInputAppointment.Appt_Date__c.month()); string day = String.valueOf(userInputAppointment.Appt_Date__c.day()); string hour = userInputAppointment.Appt_24_From_Hour__c; string minute =userInputAppointment.Appt_24_From_Min__c; string second = '00'; string stringDate = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second; Datetime startTime= datetime.valueOf(stringDate);
test case i have written for it
Appointment__c app1 = new Appointment__c(); app1.account__c=a.id; app1.Branch__c=b.id; app1.doctor__c=s1.id; app1.Appt_AM_PM__c='am'; app1.Appt_Date__c=date.ValueOf('2011-09-21'); app1.Appt_24_From_Hour__c='11'; app1.Appt_24_From_Min__c = '60'; string year = String.valueOf(app1.Appt_Date__c.year()); string month = String.valueOf(app1.Appt_Date__c.month()); string day = String.valueOf(app1.Appt_Date__c.day()); string hour = app1.Appt_24_From_Hour__c; string minute =app1.Appt_24_From_Min__c; string second = '01'; string stringDate = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second; Datetime startTime= datetime.valueOf(stringDate);
but i am getting this error
System.TypeException: Invalid date/time: 2011-9-21 11:null:00
plz help me how to cover the test case for the date part in the controller
try this instead of above,
app1.Appt_Date__c = System.today();
thanks for the reply but i am gettin the same error any more suggestions my dear friend
Though I don't understand what you are exactly doing, why do you need to put '60' into minute?
'11:60:01' looks very invalid as time.
sorry but even if i give 30 40 any thing its giving me the same error
Date formats....
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_dateformats.htm
No, It's not SOQL..
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm
srikanth11, are you sure that the exception comes from the last line of the test code?
what if you try this instead? (just for check)