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?


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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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