I'm trying to display some data on a visualforce page. There is an edit button that allows editing and on click of save, it saves the data back to the salesforce record. Data is showing up properly on the visualforce page. The issue is with the date, even though it shows properly on the page. I have 2 methods, fetchData for displaying on page load and saveData to saveData back on click of Save.
@RemoteAction
public static skuWrapper fetchData(String MasterId){
List<HEP_SKU_Master__c> lstSKUData = [SELECT Name,SKU_Number__c,Channel__c,Format__c,Barcode__c,
Current_Release_Date__c FROM HEP_SKU_Master__c where ID =: MasterId];
skuWrapper objSKUData = new skuWrapper();
objSKUData.sSKUName = lstSKUData[0].Name;
objSKUData.sSKUNumber = lstSKUData[0].SKU_Number__c;
objSKUData.sChannel = lstSKUData[0].Channel__c;
objSKUData.sFormat = lstSKUData[0].Format__c;
objSKUData.sBarcode = lstSKUData[0].Barcode__c;
objSKUData.dtReleaseDate = lstSKUData[0].Current_Release_Date__c;
return objSKUData;
}
saveData :
@RemoteAction
public static void saveData(skuWrapper objSKUData){
System.debug('objSKUData updated **** ' +objSKUData);
HEP_SKU_Master__c objSKURecord = new HEP_SKU_Master__c();
//objSKURecord.Name = objSKUData.sSKUName;
objSKURecord.SKU_Number__c = objSKUData.sSKUNumber;
objSKURecord.Channel__c = objSKUData.sChannel;
objSKURecord.Format__c = objSKUData.sFormat;
objSKURecord.Barcode__c = objSKUData.sBarcode;
objSKURecord.Current_Release_Date__c = objSKUData.dtReleaseDate;
System.debug('objSKURecord OBJECT DATA TO UPDATE ****' + objSKURecord);
update objSKURecord;
}
Below is the wrapper
public class skuWrapper{
public string sSKUName {get;set;}
public string sSKUNumber {get;set;}
public string sChannel {get;set;}
public string sFormat {get;set;}
public string sBarcode {get;set;}
public string sComments {get;set;}
public Date dtReleaseDate {get;set;}
}
Getting this error when I'm trying to update data. It displays fine on page, throws the error when I try to save date back to salesforce record. When I did a console log to check what date value I'm getting. I found the value to be :
"dtReleaseDate":1522540800000
Also I did a system debug in apex controller to check the value there and it shows the date as
dtReleaseDate=2018-04-01 00:00:00
I'm not sure about the issue. Can someone help me with a fix or a workaround?