You need to sign in to do that
Don't have an account?
Date Time Formatting
Hi,
I want to convert datetime value
i.e. currently I am getting value "Mon Aug 26 11:49:39 GMT 2013" and I want to convert it to "26-Aug-13 11:49 PM"
Any Ideas?
I want to apply formatting on standard "CreatedDateTime" field.
Check this
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm
You will get the format method there.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Now i am getting below error.
Unrecognized format: dd-MMM-YY hh:mm a
could you post your code.
What happens if you just run those 2 lines in execute anonymous?
String strDateTime = con.createdDate.format('dd-MMM-YY hh:mm a');
where con is object of Contact. I does not giving me compile error but it throws runtime error.
https://docs.google.com/file/d/0B6cPMtpRoi9FUElZRkF3MmtMV2c/edit?usp=sharing
Which editor are you using? The screenshot does not look like Eclipse or Developer Console (I tried it in both, worked ok). Also, I noticed you have 'CreateDate' field. Is it Date or DateTime, the code will work on DateTime types not on Date objects
A colleague managed to replicate your issue. It does not work in old sandboxes. If you have a recently refreshed box try it there
https://workbench.developerforce.com/select.php
you can login using your salesforce account.