Home SALESFORCEAPEX Different Date Formats Using Apex and Visualforce
public with sharing class clsDateFormat {
Datetime myDateTime = system.now();
  List dateFormats = new List {
     ‘dd.MM.yy HH:mm:ss’,
     ‘MMMMM dd, yyyy hh:mm:ss a’,
     ‘MMM-dd-yyyy hh:mm a’,
     ‘EEEEE dd MMMMM yyyy G’,
     ‘E hh:mm:ss:SSS z’,
     ‘zzzzz (Z), \’Day of the year:\’ D’
  public DateTime getMyDateTime(){
    return myDateTime;
  public List getDateFormats(){
    return dateFormats;

Demo https://sfdevforce-developer-edition.na12.force.com/DateFormat

You may also like

Leave a Comment