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.

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 :

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 :


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?

  • Please edit this post give some context as to what you are actually doing in your code. Without that, trying to help you is at best a guessing game.
    – Adrian Larson
    Commented Apr 7, 2018 at 20:07
  • Please include your code. Descriptions about your code help but are not enough to diagnose the issue.
    – Adrian Larson
    Commented Apr 7, 2018 at 20:13
  • @AdrianLarson does this give you some insight>
    – Ashu
    Commented Apr 7, 2018 at 20:20
  • 1
    Try this: @RemoteAction and Date arguments from javascript.
    – Keith C
    Commented Apr 7, 2018 at 20:55

1 Answer 1


Looks like you are trying to assign an epoch to a Date data type.

In order to do so first create a DateTime field from your epoch (note to append the L to your epoch to create a long value):

DateTime d = DateTime.newInstance(1522540800000L);

You can then convert your DateTime to a Date:

Date dt = Date.newinstance(d.year(), d.month(), d.day());

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .