How to convert US to UK time zone in Salesforce?

format(String, String) is used to change the time zone.

Sample Code:

Visualforce page:

<apex:page controller="Sample">
Current Date in US : {!USDateTime}


Current Date in UK : {!UKDateTime}

Apex Controller:

public class Sample {
    public String USDateTime {get;set;}
    public String UKDateTime {get;set;}  
    public Sample() {
        DateTime temp =;
        USDateTime = temp.format('MM/dd/yyyy HH:mm:ss', 'America/New_York');
        UKDateTime = temp.format('MM/dd/yyyy HH:mm:ss', 'London');      



No comments:

Post a Comment