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
CooldayCoolday 

I want to change the Date Time format of below line to YYYY-MM-DDT00:00:00Z

I want to change the Date Time format of below line to YYYY-MM-DDT00:00:00Z

att.Time = acc.Time__c != null ? String.valueof(acc.Time__c ) : null;

Thanks and Regards

 
Best Answer chosen by Coolday
AnkaiahAnkaiah (Salesforce Developers) 
try with below.
 
att.Time = acc.Time__c != null ? String.valueof((acc.Time__c).format('yyyy-MM-dd\'T\'HH:mm:ss.SSSXXX')) : null

 

All Answers

AnkaiahAnkaiah (Salesforce Developers) 
Hi,

Refer the below link have solution for similar kind of ask.
https://salesforce.stackexchange.com/questions/122694/how-to-convert-date-to-format-yyyy-mm-ddthhmmss-hhmm

If this helps, Please mark it as best answer.

Thanks!!
CooldayCoolday

Hi Ankaiah, 

Is it possible that manipulations can be done on this line itself -

att.Time = acc.Time__c != null ? String.valueof(acc.Time__c ) : null;
 

AnkaiahAnkaiah (Salesforce Developers) 
Hi,

what is the data type of Time__c field? 

Thanks!!
CooldayCoolday
DateTime
AnkaiahAnkaiah (Salesforce Developers) 
Hi,

try with below code.
att.Time = acc.Time__c != null ? String.valueof(acc.Time__c).format('yyyy-MM-dd\'T\'HH:mm:ss.SSSXXX') : null

If this helps, Please mark it as best answer.

Thanks!!
CooldayCoolday
I am getting this error on the above line -

Method does not exist or incorrect signature: void format(String) from the type String
AnkaiahAnkaiah (Salesforce Developers) 
try with below.
 
att.Time = acc.Time__c != null ? String.valueof((acc.Time__c).format('yyyy-MM-dd\'T\'HH:mm:ss.SSSXXX')) : null

 
This was selected as the best answer