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
Soumya sri yaravaSoumya sri yarava 

hi, how to convert date time to string in apex , geting the error while converting

i have a date of format:
   "Join_Date": "2020-06-16T00:00:00",

Datetime joindate ;
trying to convert it , but getting the different date, may i know the reason ,

i have tried with two ways. ho/ to convert to  06/16/2020 in stirng , i have tried differnety ways 
//String dateOutput = joindate.format('dd/MM/yyyy');
 
String myDate = string.valueOf(joindate );
but iam getting 06/15/2020  instead of 06/16/2020 .

please let me know where iam wrong, .. 

thanks
soumya




 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Sowmya,

I found the below thread on stackexchange that could help you could you please look at it once:

>> https://salesforce.stackexchange.com/questions/156911/datetime-to-date-to-string#:~:text=String%20iso8601%20%3D%20Datetime.,to%20format%20for%20your%20integration.

I hope this helps.

Regards,
Anutej