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
AlecSAlecS 

Date format not working as specified

I have an Apex page that defines the format of  a date field.

 

<apex:page standardController="Invoice__c" extensions="ApexButtonPageController" action="{!doMyApexLogic}">

<apex:outputText value=" {0,date,MM.dd.yyy}">
<apex:param value="{!Invoice__c.Invoice_Due_Date__c}" /> 

</apex:outputText>
</apex:page>

 However, the output of the date field, Invoice__c.Invoice_Due_Date__c is 

 

2013-03-11 00:00:00

 

How can I fix this?

 

Thank you.

Chamil MadusankaChamil Madusanka

Please try highlighted changes.

 

<apex:page standardController="Invoice__c" extensions="ApexButtonPageController" action="{!doMyApexLogic}">

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

</apex:outputText>
</apex:page>

  

If you got the answer from this post, Please give a Kudos.

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

MagulanDuraipandianMagulanDuraipandian

https://sites.google.com/site/infallibletechie/how-to-set-date-format-for-apex-outputtext

 

Check this..

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution and give Kudos.

AlecSAlecS

Thanks Chamil, but it didn't work. I still get the same format.

Chamil MadusankaChamil Madusanka

I retest the code and it works fine. I test that with both Date and Date time fields.