function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Udaya BhaskarUdaya Bhaskar 

Help needed on Date stringg

Hi All,
we have a requirement in which we are creating contract using API methods create. we are facing issue
in setting Date. I need to populate the date in this format with time stamp also..20070914T-0102. i need to move this value in to Start Date of contract. please help me how to do this..
[please don't post the same question to multiple forums]

Are you using the partner or enterprise wsdl ? if you're on the enterprise wsdl, then there'll be a setter that take a java calendar or date.
Udaya BhaskarUdaya Bhaskar
I am using Enterprise WSDL. Can you please give me  little more explanation on how to SET date. one sample example will be really more helpful,if possible. Thanks in advance.
foo.setStartDate(new Date());
Udaya BhaskarUdaya Bhaskar

Hi Simon,

Thanks a lot for the help. But it is not solving my requirement. Currently i am reading the data from a

ORACLE database and using API ia m creating a contract. When i try to set the startdate with the value available in is not working as expected.

ContractObjects[cnctCount].setStartDate(new Date(16092007)); My intension is to populate the date as it is into Salesforce.Instead it is showing as 01/01/1970. Please tell me why it is appearing like that.

in oracle table, they also have Timestamp appended to the date..and we need to move the whole 30 characters of date value to Contract start date. Please tell me how can this be achieved.



java.util.Date is a date time value, it has various contructors, but i'm very suspect of your reverse date as a number, you should check the docs
Udaya BhaskarUdaya Bhaskar

Hi  Simon,

Thanks a lot for all the help. I still require your help in this regard. We had a discussion with our client on requirements and came to know that they are not interested to see the whole 30 characters in Date field.

Currently, i get the date value in 1999-01-01T23:01:01+01:00 this format.and i am trying to parse the data and populate the Contract start date with 19990101(yyyymmdd) as it is. But when you update in sfdc, the date it considers is US Date( our dates will be one day behind). We just want the to fill the date as it is.Currently this feature is handled in apex data loader. They are loading in YYYY-MM-DDThh:mm:ss+hh:mm this format to handle the date issue( US Date, one day behind actual date) and is getting displayed on the screen in mm/dd/yyyy format. Can you please help me out in handling this issue in API.





Michael SnowMichael Snow
How are you getting your date out of Oracle?  Are you using the JDBC?  If so, ResultSet.getDate(i) returns a java.sql.Date.  You can create a java.util.Date as follows:
java.sql.Date lSDate = //get date from db
java.util.Date lUDate = new java.util.Date(lSDate.getTime());

then just use Contract.setStartDate(lUDate);

All of these dates are based on GMT, so that shouldn't be a problem for your time zone.

If you can only get the date as a java.lang.String, you will need to parse it.  I would suggest creating a java.util.Calendar with your timezone and locale, then set the different parts of the date/time as needed.  Using the Calendar object, create a java.util.Date using the same method as above: java.util.Date = new java.util.Date(Calendar.getTime()).  You can also use java.text.DateFormat to parse your string.