Sign up ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am trying to use a utility method to format the date which is coming as a string. The method is a static method which accepts string as a parameter and returns a formatted date.


public with sharing class Utility {
   public static String FormatDate(String s) {
        if(s != null || s!= '') {
            String[] dt = s.split('-');
            return dt[1]+'-'+dt[2]+'-'+dt[0];
        } else {
            return '';


Visualforce code:

<apex:page controller="ExportController" contentType="text/csv#{!fileName}.csv" 
        showHeader="false" sidebar="false" standardStylesheets="false">
    "Order #","Document Date","Purchase Order #","Sales Org","Amount","Currency","Products"
     <apex:repeat value="{!OpenSalesOrders}" var="oso">


Unknown function Utility.FormatDate. Check spelling.

How to call a static method in an expression in visualforce page? Any ideas?

share|improve this question

1 Answer 1

Unfortunately (and perhaps surprisingly) you can't in a Visualforce expression.

See this answer Rendering a Conditional Format for VisualForce Table Cell for the normal work-around of using a wrapper class.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.