You need to sign in to do that
Don't have an account?
NishaC
Getting Error: Invalid Integer.. when converting string to integer
i have used this method for converting string date to integer date
String[] myDateOnly = dateFrom.split(' ');
String[] strDate = myDateOnly[0].split('/');
Integer myIntDate = integer.valueOf(strDate[0]); //getting error: invalid Integer
Integer myIntMonth = integer.valueOf(strDate[1]);
Integer myIntYear = integer.valueOf(strDate[2]);
Date d = Date.newInstance(myIntYear, myIntMonth, myIntDate);
Please help me in this
Hi NishaC
Use this Snippt given below:
String strDate = '12/12/2009';
String[] myDateArray = strDate.split('/');
Integer myIntDate = integer.valueOf(myDateArray[0]);
Integer myIntMonth = integer.valueOf(myDateArray[1]);
Integer myIntYear = integer.valueOf(myDateArray[2]);
Date d = Date.newInstance(myIntYear, myIntMonth, myIntDate);
System.debug('***'+d);
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Thanks & Regards
Tej Pal Kumawat
(Certified Developer) | http://salesforce-evershine-knowledge.blogspot.in/
All Answers
Please use system debug to see the value of myDateOnly and strDate field. This will help you to check if you are getting the value as expected after the split.
debugs:
actually i am selecting value from calendar....at starting it is blank value and after selecting any value and clicking on GO button
it again displays blank value
Hi NishaC
Use this Snippt given below:
String strDate = '12/12/2009';
String[] myDateArray = strDate.split('/');
Integer myIntDate = integer.valueOf(myDateArray[0]);
Integer myIntMonth = integer.valueOf(myDateArray[1]);
Integer myIntYear = integer.valueOf(myDateArray[2]);
Date d = Date.newInstance(myIntYear, myIntMonth, myIntDate);
System.debug('***'+d);
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Thanks & Regards
Tej Pal Kumawat
(Certified Developer) | http://salesforce-evershine-knowledge.blogspot.in/