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

System.StringException: Starting position out of bounds: 11 exception help needed
Hi All,
I am getting the below exception
System.StringException: Starting position out of bounds: 11 Class.Test.datecalculation: line 29
Please help me the issue here
ERROR LINE :
string hour = firstDate.substring(11,13);
Kindly help me on the same,
Thanks in advance
I am getting the below exception
System.StringException: Starting position out of bounds: 11 Class.Test.datecalculation: line 29
Please help me the issue here
public class test { public static void datecalculation(List<Case> caseList ) { if(caseList.size() >0 ) { List<Case> caseList2 = new List<Case>(); for(Case c: caseList) { if(c.Departure_Date_Time__c!=null){ //Case ca = new Case(); String firstDate = c.Departure_Date_Time__c; String month = firstDate.substring(3,5); String day = firstDate.substring(0,2); String year = firstDate.substring(6,10); string hour = firstDate.substring(11,13); string minute = firstDate.substring(14,16); string second = firstDate.substring(17,19); string stringDate = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second; System.debug('stringDate:'+stringDate); Date myDate = Date.valueOf(stringDate); c.Updated_Departure_Date_Time__c = myDate; } } } } }
ERROR LINE :
string hour = firstDate.substring(11,13);
Kindly help me on the same,
Thanks in advance
Hope that your day is off to an amazing start. You're getting this error because the starting index doesn't exist, blank space, or null. Please try any of the code below and hope this helps. May God bless you abundantly.
Best Regards,
Anthony McDougald
All Answers
Hope that your day is off to an amazing start. You're getting this error because the starting index doesn't exist, blank space, or null. Please try any of the code below and hope this helps. May God bless you abundantly.
Best Regards,
Anthony McDougald