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

Written by 

2x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

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