APEX:
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;
  }
}
VisualForce:
 
    
   
    
   
       
           
           
               
                   
               
           
       
   

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

Written by 

Salesforce MVP | Lightning Champion | 17x Salesforce Certified | Application Architect | 7x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *

*