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
Jason FungJason Fung 

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

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?
Best Answer chosen by Jason Fung
NagendraNagendra (Salesforce Developers) 
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