In a visual force page, I can take a date and do this…
<apex:outputText value="{0,date, MMMM d, yyyy}">
<apex:param value="{!relatedTo.my_date__c}"/>
</apex:outputText>
I want to be able to do that in Apex code. So I want a method which takes a date and returns a certain format as a string.
I check the API: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_date.htm and sorry if I am stupid but not so obvious how to do this?
Many thanks.
Best Answer
UPDATE
For the following format
please use:
Im using the following functions for the timestamp:
And my output looks like this then: 2013.02.08 08:30:56