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
Pedro PaivaPedro Paiva 

Datetime format from Drive Api Human Readable

Hi, i am struggling to properly show the modifiedTime got from the Google Drive API in a more human readable way.

My first tough was to first convert the field (modifiedTime) into DateTime object, but i am having issues with the format.

This is the date i am getting from the API : 2018-03-21T18:49:58.867Z  and i would like to show it in a more human readable way, maybe like this: 21 March 2018, 6:49 pm

I tried to do this: 
String modifiedTime = String.valueOf(mapResultFile.get('modifiedTime'));
Datetime dt = Datetime.parse(modifiedTime);

// OR

String format = 'yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'';
DateTime dt = new DateTime();
dt.format(format);
But without success, i searched if Apex has something like SimpleDateFormat like Java to try something like this, but couldn't find some good example of it in Apex.

Any help would be appreciate, thanks in advance.
 
Pedro PaivaPedro Paiva
I found a way to convert that specific format to Datetime in Apes, that format is called ISO-8601

https://salesforce.stackexchange.com/questions/1013/parsing-an-iso-8601-timestamp-to-a-datetime

Now i need to convert the DateTime in a more human readable way