I am trying to convert salesforce standard field CreatedDate to logged-in user's timezone. I am using following code
Datetime dt = Datetime.newInstance(a.CreatedDate.dateGmt(),a.CreatedDate.timeGmt());
But this is not giving right result.
for e.g. I have created a record at 11/12/2012 12:50 PM (in GMT+5:30)
. Now when another user (in GMT-5:00) logs into the system and run the above code in developer console then he should see 11/12/2012 2:20 AM
but he sees 11/12/2012 5:50 AM
.
What I am doing wrong? Any Thoughts?