function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
S GogatiS Gogati 

I want to show the LastModified Date in user's Local time Zone

Hi Team,

I Need to show the LastModified Date in user's Local time Zone, Using SOSL am getting data from salesforce. And trying with bellow method, but no luck.
Can anyone help on this?

 public static String formatDateBasedOnLocale( String value ) {
        /*DateTime dateTimeToFormat = DateTime.valueOf( value );
        Date dateToFormat = dateTimeToFormat.date();
        return dateToFormat.format();*/
     /*String timeZone = UserInfo.getTimeZone().getID();
     Datetime dateGMT=DateTime.valueOf( value );
     Datetime d1=Datetime.valueOf(dateGMT);
     return d1.format();*/
     System.debug('UserInfo.getTimeZone().getID() '+UserInfo.getTimeZone().getID());
     System.debug('value  '+value );
     DateTime param_time= DateTime.valueOf( value );
     string var_time = param_time.format('yyyy-MM-dd HH:mm:ss',UserInfo.getTimeZone().getID());
     return datetime.valueOf(var_time).format();

    }
 
SandhyaSandhya (Salesforce Developers) 
Hi,

Please refer below sample code from the link 
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. 

System.assertEquals('06/01/2011 08:01:05', strConvertedDate);

http://salesforce.stackexchange.com/questions/4279/createddate-in-users-local-timezone
 
Hope this helps you!

Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
 
Thanks and Regards
Sandhya