[SalesForce] Datetime input field cast to another timezone

Is there a way to cast the input of a timedate field to another timezone's GMT…?

If the user is in say: MDT, an input of 12:00, will be saved as 18:00, but if I want that value to be in EDT, I need the value to be saved as 16:00GMT

Best Answer

The datetime in salesforce is always stored in GMT (UTC). The time is corrected to the users time zone when displaying it on the UI.

Datetime GMTDate = 
  Datetime.newInstanceGmt(2011,6,1,12,1,5);
String strConvertedDate = 
  GMTDate.format('MM/dd/yyyy HH:mm:ss', 
                 'America/New_York');
// Date is converted to the new time zone and is //adjusted for daylight saving time. 

Valid time zone values for the timezone argument are the time zones of the Java TimeZone class that correspond to the time zones returned by the TimeZone.getAvailableIDs method in java