If you have to format Date fields directly on VF page, then you can use below code snippets to achieve this.
<apex:page standardController="Opportunity">
<!--display=10/25-->
<apex:outputlabel value="Opportunity Close date (MM/dd):" />
<apex:outputText value="{0,date,MM/dd}">
<apex:param value="{!opportunity.CloseDate}" />
</apex:outputText>
<br/>
<!--display=October 25-->
<apex:outputlabel value="Opportunity Close date (MMMM dd): " />
<apex:outputText value="{0,date,MMMM dd}">
<apex:param value="{!opportunity.CloseDate}" />
</apex:outputText>
<br/>
<!--display= display=25 October-->
<apex:outputlabel value="Opportunity Close date (dd MMMM): " />
<apex:outputText value="{0,date,dd MMMM}">
<apex:param value="{!opportunity.CloseDate}" />
</apex:outputText>
<br/>
<!-- display=DD/MM-->
<apex:outputlabel value="Opportunity Close date (DD/MM): " />
{!Day(opportunity.CloseDate)}/{!Month(opportunity.CloseDate)}
</apex:page>
Output on VF Page:
08/06
August 06
06 August
6/8
<apex:page standardController="Opportunity">
<!--display=10/25-->
<apex:outputlabel value="Opportunity Close date (MM/dd):" />
<apex:outputText value="{0,date,MM/dd}">
<apex:param value="{!opportunity.CloseDate}" />
</apex:outputText>
<br/>
<!--display=October 25-->
<apex:outputlabel value="Opportunity Close date (MMMM dd): " />
<apex:outputText value="{0,date,MMMM dd}">
<apex:param value="{!opportunity.CloseDate}" />
</apex:outputText>
<br/>
<!--display= display=25 October-->
<apex:outputlabel value="Opportunity Close date (dd MMMM): " />
<apex:outputText value="{0,date,dd MMMM}">
<apex:param value="{!opportunity.CloseDate}" />
</apex:outputText>
<br/>
<!-- display=DD/MM-->
<apex:outputlabel value="Opportunity Close date (DD/MM): " />
{!Day(opportunity.CloseDate)}/{!Month(opportunity.CloseDate)}
</apex:page>
Output on VF Page:
08/06
August 06
06 August
6/8
More Blogs>>: Round Off Field Values in VF page
Batch Apex Job Progress Bar
Dynamic Apex in Salesforce
Refer Below Links for Salesforce Interview Questions
No comments:
Post a Comment