+ Start a Discussion
PriaviPriavi 

System.TypeException: Invalid date/time: 2021-12-07T15:32:19.583

String fake = '2021-12-07T15:32:19.583';
DateTime t = DateTime.valueOfGmt(fake);
system.Debug('Line 17:' + t);
Best Answer chosen by Priavi
Suraj Tripathi 47Suraj Tripathi 47
Hi Pritam,
Please try this:

String fake = '2021-12-07T15:32:19.583';
DateTime t = DateTime.ValueofGmt(fake.replace('T', ' ')); 
system.Debug('Line 17:' + t);

Hope this will help you.
Thanks

All Answers

Suraj Tripathi 47Suraj Tripathi 47
Hi Pritam,
Please try this:

String fake = '2021-12-07T15:32:19.583';
DateTime t = DateTime.ValueofGmt(fake.replace('T', ' ')); 
system.Debug('Line 17:' + t);

Hope this will help you.
Thanks
This was selected as the best answer
PriaviPriavi
Hi Suraj,
it works, Thank you
i try to use .format