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
Agent Comms 7Agent Comms 7 

Date format changes if the page s refrehed

Hi..I have a input date field in a vfpage where I have used a datepicker. When I select a date from here and the page somehow gets refreshed it shows error-
""Value 'Sat Jan 30 00:00:00 GMT 2016' cannot be converted from Text to com.force.swag.soap.DateOnlyWrapper""
Can anyone tell me why this error is coming
Swayam@SalesforceGuySwayam@SalesforceGuy
You need to format the date using Date.format in your controller.

Sample Code 

VF :- 
 
<apex:pageBlockSectionItem >
   <apex:outputLabel value="From Due Date" for="fromDate"/>
   <apex:inputText value="{!fromDateCriteria}" size="10" onfocus="DatePicker.pickDate(false, this, false);" id="fromDate" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >

Controller :
 
private Date FromDateCriteria;
private Date ToDateCriteria;

public void setFromDateCriteria(Date FromDateCriteria) {
    this.FromDateCriteria = FromDateCriteria;
}
public String getFromDateCriteria() {
    //you can put a null check here  
    return FromDateCriteria.format();
}

public void setToDateCriteria(Date ToDateCriteria) {
    this.ToDateCriteria = ToDateCriteria;
}
public String getToDateCriteria() {
    //you can put a null check here   
    return ToDateCriteria.format();
}

Hope this helps,

--
Thanks,
Swayam