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
Chenna4a2Chenna4a2 

Need to convert String (2013-10-22T00:00:00-07:00) Date Format to Date (MM/DD/YYYY )

HI,

 

I am getting in this format from integration

 

2013-10-22T00:00:00-07:00

 

Need to convert  like 10/30/2011( MM/DD/YY)

 

Thanks in Advance

Chenna4a2Chenna4a2

I am trying just like this:   Not working 

 

if (otest.get('DueDate') != null){

string deliveryDate = (String)oSODO.get('DeliveryDate');
oLineitem.Due Date__c = Date.newInstance(Integer.valueOf(arr_Date[0]), Integer.valueOf(arr_Date[1]), Integer.valueOf(arr_Date[2]));


}

 

Please help ???

Grazitti InteractiveGrazitti Interactive

Hi,

 

Use Following formate to do this :

 

Datetime myDT = Datetime.now();
String myDate = myDT.format('dd/MM/yyyy');
system.debug(myDate);

 

Thanks,

www.grazitti.com

Chenna4a2Chenna4a2
Hi, I am trying like this

if(oSODO.get('DeliveryDate') != null)
{
String myDate = (String)oSODO.get('DeliveryDate');
Datetime myDT = Datetime.now();
String myDate = myDT.format('MM/dd/yyyy');
system.debug(myDate);
oLineitem.DO_Ship_Date__c = myDate;

}

Not working . can you please help me ??

Error Message : Error: Compile Error: Illegal assignment from String to Date
Grazitti InteractiveGrazitti Interactive

Hi,

 

Please see inline comment :

 

if(oSODO.get('DeliveryDate') != null)  // It will work fine
{
String myDate = (String)oSODO.get('DeliveryDate');// It will work fine
Datetime myDT = Datetime.now();// It will work fine
String myDate = myDT.format('MM/dd/yyyy');// It will work fine
system.debug(myDate);// It will work fine
oLineitem.DO_Ship_Date__c = myDate; /* DO_Ship_Date__c is of Datatype either Datetime or Date , Salesforce does not support like MM/dd/yyyy formate with this data type. if you want MM/dd/yyyy formate then convert data type of DO_Ship_Date__c to Text or delete it and create a new Text field with same Name  having Text data type.*/

}