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
bohemianguy100bohemianguy100 

display task activity date in mm/dd/yyyy format

How can I display the task activity date in the mm/dd/yyyy format on a visualforce page?  I have a custom page with an inputText that uses a DatePickerComponent, that will initially put the date into the correct format...i.e. 8/12/2013.  After saving the record and returning to the page to edit the record, the date is then in the format of: Mon Aug 12 00:00:00 GMT 2013, so if I try and update, it throws the error:

 

Value 'Mon Aug 12 00:00:00 GMT 2013' cannot be converted from Text to Date

 

How can I resolve this issue?

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
amarcuteamarcute

Hi,

 

Use <apex:inputField> instaed of <apex:inputText> if that is usable in your case. <apex:inputField> will bring up the default  Salesforce.com Date Picker for the input fields.

 

<apex:inputField id="taskDueDate" value="{!task.taskLine.ActivityDate}" />

 

All Answers

amarcuteamarcute

Hi,

 

You can specify the format of date as shown below:

 

<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
    <apex:param value="{!contact.Birthdate}" /> 
</apex:outputText>

link to full doc can be found @ http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_outputText.htm

bohemianguy100bohemianguy100

That doesn't work with an inputText component, which is what I'm using.  That only works with outputText.

 

<apex:inputText id="taskDueDate" value="{!task.taskLine.ActivityDate}" onfocus="DatePicker.pickDate(true, '{!$Component.taskDueDate}', false);" />
            			<c:DatePickerComponent dateFieldId="{!$Component.taskDueDate}" />

 

amarcuteamarcute

Hi,

 

Use <apex:inputField> instaed of <apex:inputText> if that is usable in your case. <apex:inputField> will bring up the default  Salesforce.com Date Picker for the input fields.

 

<apex:inputField id="taskDueDate" value="{!task.taskLine.ActivityDate}" />

 

This was selected as the best answer