You need to sign in to do that
Don't have an account?
Vidya D
Convert String to Date - Exception in US locale when DateString has -
I am trying to parse Date string to Date data type
While executing Anonymous code below
Date Birthdate = date.parse('09-05-1954');
The System date format is current user's Time Zone date format. So All of dates format is the same. then Date Birthdate = date.parse('09-05-1954'); If this value is from page, then its format should be system date format:09/05/1954.
Hope this helps.
Thanks,
Samba
Yes, parsing dates entered from external systems is a pain in Salesforce as the SFDC date parsing is limited. I use this Utility class method to parse dates in locale or yyyy-mm-dd format and it could be extended for other allowed formats
Note that if you need to parse dates from a VF page, then I strongly recommend changing the VF apex:inputText component to apex:inputField and associate that inputField to an SObject field, even to the extent of creating new SObject fields of type Date if necessary. In this way, you will always get a valid date from the user input and you won't care about these locale issues
Try giving date in the format yyyy-mm-dd. It should work.
Hey there,
parse(stringDate)
Constructs a Date from a String. The format of the String depends on the local date format.
So, try to put date of your org date type like Date d= date.parse('09/05/2000'); || Date d= date.parse('2000/09/05'); ||
Mark best answer if its work.