I develop a webservice i am getting the date 12/9/2013 format while i am inserting this date in opportunity object but the date which comes from thirdparty system is not inserting exactly.

my code is for date insert.

Opportunity o = new Opportunity();
o.Name = rName; // rName Which Coming from Third Party system
o.CloseDate = ocDate; // when i map like this means it not taking may i know i want to da any modifications the date which was given by third party system that data must be insert in sfdc
insert o;
  • debug and find what is format of ocDate from the webservice ? – Mohith Shrivastava Dec 6 '13 at 7:53
  • The format of ocdate is webservice Date ocDate; – Sathya Dec 6 '13 at 7:58
  • What do you mean by is not inserting exactly? What is the error?. If I understand correctly, the date format you are receiving is not the one salesforce is expecting, you will need to manipulate it before inserting if that is the case. – PepeFloyd Dec 6 '13 at 8:28
  • 2
    @Sathya Still you are not specific here .Please be crystal clear .put some logs and check the issue – Mohith Shrivastava Dec 6 '13 at 8:47
  • 2
    Is that really your code? You're inserting 0 (the number zero), not o. – FrankZ Dec 6 '13 at 8:50
     Try this code

    String[] str = ocDate.split(' ');
    String[] dts = str[0].split('/');

    Date myDate = date.newinstance(Integer.valueOf(dts[2]), Integer.valueOf(dts[0]), Integer.valueOf(dts[1]));

o.CloseDate = myDate;
insert o;

date.newinstance(year,month,date) format

Refer the link link

  • It's working for me thanq for giving response. – Sathya Dec 6 '13 at 10:06
  • hello @sathya, if its working fro you then you should upvote the answer and accept the answer. This will bring visibility to the question and help other members of the community with similar question – Chris Duncombe Dec 6 '13 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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