1

I am trying to convert date in words as shown below: 10/07/2014

TENTH Day of JULY, TWO THOUSAND FOURTEEN

5
  • What did you try ?
    – SF_user
    Sep 22, 2014 at 8:59
  • Can you use apex? Sep 22, 2014 at 9:05
  • Date presentDate = new Date(); String value = String.valueOf(presentDate);
    – user5633
    Sep 22, 2014 at 9:05
  • Yes i can use apex
    – user5633
    Sep 22, 2014 at 9:06
  • Apex Date has methods to get a number for each part of the date; you then just need several Map<Integer, String> to translate the parts to strings (though the year part will probably need building in pieces).
    – Keith C
    Sep 22, 2014 at 10:01

1 Answer 1

1

You can build the string up in VF by something like the following. Just replace the variable today() with whatever value you need. You'll also need to fill in the extra day values, and also the years.

Note: The month comes out as July. If you need JULY then you may need to create another block of statements similar to the DAY block with the correct case included.

<apex:outputText value="FIRST" rendered="{!Day(today()) == 1}"/>
   <apex:outputText value="SECOND" rendered="{!Day(today()) == 2}"/>
   <apex:outputText value="THIRD" rendered="{!Day(today()) == 3}"/>
   <apex:outputText value="TWENTY SECOND" rendered="{!Day(today()) == 22}"/>

   &nbsp;DAY of <apex:outputText value="{0, DATE, MMMM}"><apex:param value="{!today()}" name="month"/></apex:outputText>

   , TWO THOUSAND&nbsp;
   <apex:outputText value="FOURTEEN" rendered="{!YEAR(today()) == 2014}"/>
   <apex:outputText value="FIFTEEN" rendered="{!YEAR(today()) == 2015}"/>
   <apex:outputText value="SIXTEEN" rendered="{!YEAR(today()) == 2016}"/>
2
  • Thanks it worked but need to fetch date field and then display instead of todays date.
    – user5633
    Sep 22, 2014 at 10:22
  • Add a standard controller to the page and then pull in the field from the object; or use a custom apex controller. You should be able to find examples in the docs and/or internet. Sep 22, 2014 at 10:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .