Skip to main content
1 of 3
Ideasforce
  • 1.2k
  • 2
  • 7
  • 18

Assuming all your inputs are in either CDT or CST you could do:

String[] dateTimeSplit = String.valueOf(assetActivity.get('actstart')
                .getValue()).split(' ');
Datetime dt = datetime.parse(dateTimeSplit[0] + 'T' + dateTimeSplit[1] + dateTimeSplit[2] == 'CST' ? '-06:00' : '-05:00');
system.debug('dt'+dt);
ts.Start_Time__c = dt;

Note the timezone determines the appended '-06:00' or '-05:00' if you need support for other timezones you could write an auxiliar method to calculate the appended difference to GMT.

Here you can see the format for DateTime literals.

Ideasforce
  • 1.2k
  • 2
  • 7
  • 18