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
jheuvel73jheuvel73 

Formatting <apex:outputText> in specified locale??

Hi all,

visualforce supports formatting an outputtext (date, currency, etc) using java messaging based formatter option, eg:

<apex:outputText value=", {0,date,M/d/yyyy h:mm a}">
     <apex:param value="{!Account.CreatedDate}"></apex:param>
</apex:outputText>

 

However this only works for the US locale. This is a major flaw for companies trying to develop visualforce outside of US.

I know outputField will display in the user locale, however this will not allow custom formatting. IMO we are left with a incomplete solution here.

 

Eg. if i try to display just the time part of a local time (in GMT+1 timezone) on a visualforce page, i have to use Apex to achieve this.

The same is the case when i want to use a different decimal separator on numbers.

 

An idea to fix this is already posted here: https://sites.secure.force.com/success/ideaView?id=08730000000g62yAAA

 

I would be very interested if anyone created a generic workaround for this.

 

Thanks!

 

themattythematty
try <apex:outputField value="{!Account.CreatedDate}"/>

it should display the field with the same formatting that you would see in standard Salesforce.
jheuvel73jheuvel73

Thanks for your reply, but that won't allow the formatting i would like to see.

 

I ended up writing a custom component to achieve this.