You need to sign in to do that
Don't have an account?
Sachin10
Convert Date to DD-MM-YYYY
Hi,
I would like to convert Date to String in DD-MM-YYYY format in my controller Class
I can easily convert it using format method if it is DateTime but not Date.
If I use the corresponding Date functions I'm not getting the format directly
For Eg:
date todayDate = system.today();
Now if I use todayDate.day() I get 4 not 04.
So again I need to convert this into DD format.
Is there any easy approach to convert Date to String in DD-MM-YYYY format?
Many thanks in advance!!
I would like to convert Date to String in DD-MM-YYYY format in my controller Class
I can easily convert it using format method if it is DateTime but not Date.
If I use the corresponding Date functions I'm not getting the format directly
For Eg:
date todayDate = system.today();
Now if I use todayDate.day() I get 4 not 04.
So again I need to convert this into DD format.
Is there any easy approach to convert Date to String in DD-MM-YYYY format?
Many thanks in advance!!
Even if you don't have time cast your date into datetime, then format the way you want.
All Answers
Try this example in execute anonymous to test
Hope this helps
Thanks for your reply.
As I mentioned before, I knew how to do it when it is a Date Time,but the scenarion I have is a Date field.
NOT DATETIME.
So let me know if you know anything related to the same.
Thanks!
Even if you don't have time cast your date into datetime, then format the way you want.
It worked.