CalEvent calEvent = (CalEvent) JSON.deserialize(calEventJson, Technician_Dispatch_Util.CalEvent.class);
System.debug('OGDEBUG TDU calEventJson '+calEventJson);
System.debug('OGDEBUG TDU updateTechnicianCalEvent calEvent.startTime '+ calEvent.startTime + ' calEvent.endTime '+calEvent.endTime);
15:13:56.110 (110381617)|USER_DEBUG|[185]|DEBUG|OGDEBUG TDU calEventJson {"id":zzzzzzzzzzz","title":"zzzzz New College of zzz","allDay":false,"startTime":"2015-07-27T00:00:00.000","endTime":"2015-07-27T01:00:00.000","ownerId":"zzzzzzzzzz","description":"Perform PM visit as detailed on supplied spreadsheet. Check service office's documentation for equipment list. Contact dispatcher at Help Desk with any questions. For damaged equipment please specify the following:\n\n* Room Name:\n* Manufacturer:\n* Model:\n* Serial No.:\n* Problem: \n\nROOMS TO COVER:\n\nNew College of zz- Sarasota Fl - Carriage House\n\nNew College of zz- Sarasota zz- CHL 0\n\nNew College of zz- Fl - CHL 2z1"}
15:13:56.110 (110791126)|USER_DEBUG|[186]|DEBUG|OGDEBUG TDU updateTechnicianCalEvent calEvent.startTime 2015-07-27 04:00:00 calEvent.endTime 2015-07-27 05:00:00
You can see from the above log output that the json being passed in are correct:
"startTime":"2015-07-27T00:00:00.000"
"endTime":"2015-07-27T01:00:00.000"
However after calling JSON.deserialize time is added onto them (4 hours)
calEvent.startTime 2015-07-27 04:00:00
calEvent.endTime 2015-07-27 05:00:00
Why is this and how can I prevent against it?
FYI Troubleshooting further I tried something different
Map<String, Object> resultsMap = (Map<String, Object>) JSON.deserializeUntyped(calEventJson);
String startTime = (String)resultsMap.get('startTime');//hack for issue with incorrect time saved
String endTime = (String)resultsMap.get('endTime');
This startTime will have the correct String time But I cant convert it to Datetime as I get errors
Invalid date/time: 2015-07-28T00:00:00.000