Skip to main content
Jason Fung (Sun Life Financial) a posé une question dans #Apex
I am trying to update a task from a visualforce page that I made but kept getting this error below: 

"Value 'Mon Sep 30 00:00:00 GMT 2013' cannot be converted from Text to com.force.swag.soap.DateOnlyWrapper."

Anyone knows how to solve it?
1 réponse
  1. 30 sept. 2016, 09:43
    Hi Jason,

    This is a known error of salesforce. Refer the below link and the possible workaround for it (suggested by salesforce)

    Summary

    apex:inputHidden can not handle Date(and Datatime) type variable correctly.

    Repro

    1) Create the following Apex class 

    public class W2947254 { 

    public Date dateValue { get; set; } 

    public W2947254() { 

    dateValue = Date.today(); 

    public PageReference doTest() { 

    return null; 

    2) Create the following Visualforce page: 

    Name : W2947254 

    <apex:page controller="W2947254"> 

    <apex:pageMessages ></apex:pageMessages> 

    <apex:form > 

    <apex:inputHidden value="{!dateValue}" /> 

    <apex:commandButton value="TEST" action="{!doTest}"/> 

    </apex:form> 

    </apex:page> 

    3) Access to the above VF page. You will see "TEST" button. 

    4) Click "TEST" button. You will see the following error message 

    Error: 

    Value 'Thu Feb 25 00:00:00 GMT 2016' cannot be converted from Text to com.force.swag.soap.DateOnlyWrapper 

    This is unexpected.

    Workaround:

    Use converted string value from Date type for apex:inputHidden instead of using Date type directly 

    OR 

    If using SObject's Date type field, this behavior can be avoided by using apex:inputField instead as follows: 

    <apex:inputField value="{!case.Today__c}" id="hiddenField" style="display: none" showDatePicker="false"/>

    Please mark this as best answer if it helps.

    Best Regards,

    Nagendra.P
0/9000