You need to sign in to do that
Don't have an account?
Bhushan.Adhikari
Reading a date of format 'EEE MMM dd HH:mm:ss Z yyyy' and converting to a proper dateTime format
Hello,
I am working with twitter integration and when i do a callout i get a response with a datestamp as 'Tue Jul 29 05:32:57 +0000 2014'. So I am looking for a way in salesforce to parse this date and convert it to a proper dateTime format.
Any suggestions?
Regards,
Bhushan A
I am working with twitter integration and when i do a callout i get a response with a datestamp as 'Tue Jul 29 05:32:57 +0000 2014'. So I am looking for a way in salesforce to parse this date and convert it to a proper dateTime format.
Any suggestions?
Regards,
Bhushan A
Find out a little about these methods here
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm#apex_System_Datetime_valueOf
This makes me feel a little gross, and I'm hoping another force.com expert with a little more spare brain space/experience can shed some light on this kind of parsing, but basically you may end up with something that looks like:
(hand crafted code, may be missing a semi colon or I might have mis-counted an index for sure)
I hope twitter delivers dates in 01, 02, ... 16, 17 format, or you will get one character out, of course. If they do this, you might have to use string.split() and break your string up over whitespace, and then reference the relevant section instead for the array (you will still have to use substrings to break the time down around the colons (or another split() !!!)
Either way, hacking a string up and passing it into valueOf() is my suggestion :)
Note: the finalDate string basically needs to match "“yyyy-MM-dd HH:mm:ss" and will be considered to be delivered/set in your local time zone (so you could always adjust that with the timezone in your twitter stamp?)