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
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