Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
date inn = integer.valueof(trans.stdate.trim()) + integer.valueof(payment.Net__c);

Getting the following error System.TypeException: Invalid integer: 12/06/2012

Here trans.stdate is of string Type.& My Requirement is 12/06/2012 + 4 = 12/10/2012.

How can I acheive it

share|improve this question
up vote 3 down vote accepted

Well for starters Integer + Integer == Integer so you'll never get a date with your current operation.

But if trans.stdate is a String representation of a date your code should look something like:

Date inn = Date.parse(trans.stdate) + Integer.valueof(payment.Net__c);

There is also the Date.valueOf(string) static method but that only accepts dates in the format yyyy-MM-dd so wouldn't match the format in your error message

share|improve this answer
A Big Thanks for ur Explaination – Eagerin Sf Dec 6 '12 at 9:28
any time, thank you for accepting my answer – Daniel Blackhall Dec 6 '12 at 9:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.