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
BPOORBPOOR 

Date/Timezone Issue with Apex Web service

I have an apex class making a callout to an external REST API and gets a response as shown below.
[
{
    "externalGUID": "0d872ca4-45fc-45f9-97f7-0c4f8068ea79",
    "carrierName": "ABC",
    "effectiveDate": "2020-02-19T00:00:00",
    "endDate": "2020-12-31T00:00:00",
    "renewalDate": null,
}
]
I have an apex class making a callout to an external REST API and gets a response as shown below.
[ { "externalGUID": "0d872ca4-45fc-45f9-97f7-0c4f8068ea79", "carrierName": "ABC", "effectiveDate": "2020-02-19T00:00:00", "endDate": "2020-12-31T00:00:00", "renewalDate": null, } ]
The effectiveDate and endDate (datetime fields) are passed as CST times from the external system. However, when I use the apex code to populate the details on the Salesforce Asset object, the effectiveDate and endDate are off by 2 days. If I use it as GMT time, these dates are off by 1 day.
Below is the apex code that I am using to populate the info on Asset object.
 
template.effectiveDate = (oprResponse.effectiveDate==null)?null:(date.newInstance(oprResponse.effectiveDate.yearGmt(),oprResponse.effectiveDate.monthGmt(),oprResponse.effectiveDate.dayGmt()));
        template.endDate = (oprResponse.endDate==null)?null:(date.newInstance(oprResponse.endDate.yearGmt(),oprResponse.endDate.monthGmt(),oprResponse.endDate.dayGmt()));
        template.renewalDate = (oprResponse.renewalDate==null)?null:(date.newInstance(oprResponse.renewalDate.yearGmt(),oprResponse.renewalDate.monthGmt(),oprResponse.renewalDate.dayGmt()));

The template.effectiveDate is populated on the InstallDate in Asset object at a later part of the code.
How do I make sure to integrate the effectiveDate and other dates as CST dates in Salesforce? Can someone help?