It worked fine with "1980-08-08" as mentioned below -
public void testInsertInContactsWithBirthdate() throws Exception {
if (!isConfigured()) {
System.err.println(getInvalidConfigurationMessage());
return;
}
SalesforceDataContext dc = new SalesforceDataContext(getUsername(),
getPassword(), getSecurityToken());
final String tableName = "Contact";
final String firstName = "rob";
final String lastName = "john";
final String date = "1980-08-08";
SimpleDateFormat format = new
SimpleDateFormat(SalesforceDataContext.SOQL_DATE_FORMAT_IN);
final Date dateValue = format.parse(date);
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.insertInto(tableName).value("FirstName",
firstName).value("LastName", lastName).value("BirthDate",
dateValue).execute();
}
});
}
-Balendra
On 23 August 2013 13:08, Balendra Singh <[email protected]> wrote:
> Hi,
>
>
> I added a test in SalesforceDataContextTest to insert the record in
> contacts table in saleforce. This record has a birthdate value with format
> as (SOQL_DATE_FORMAT_IN = "yyyy-MM-dd";).
>
> *public void testInsertInContactsWithBirthdate() throws Exception {*
> * *
> * *
> * if (!isConfigured()) {*
> * System.err.println(getInvalidConfigurationMessage());*
> * return;*
> * }*
> * *
> * SalesforceDataContext dc = new SalesforceDataContext(getUsername(),
> getPassword(), getSecurityToken());*
> *
> *
> * final String tableName = "Contact";*
> * final String firstName = "rob";*
> * final String lastName = "john";*
> * final String date = "08-08-1980";*
> * *
> * SimpleDateFormat format = new
> SimpleDateFormat(SalesforceDataContext.SOQL_DATE_FORMAT_IN);*
> * final Date dateValue = format.parse(date);*
> * *
> * dc.execu*teUpdate(new UpdateScript() {
> * @Override*
> * public void run(UpdateCallback callback) {*
> * callback.insertInto(tableName).value("FirstName",
> firstName).value("LastName", lastName).value("BirthDate",
> dateValue).execute();*
> * }*
> * });*
> * *
> * }*
>
> I am not able to insert this record in salesforce due to
> FIELD_INTEGRITY_EXCEPTION for date as shown in below -
> *
> *
> *java.lang.IllegalStateException: 1 out of 1 object(s) could not be
> inserted in Salesforce! The first error message was: *
> *'Birthdate: invalid date: Sun Dec 31 00:00:00 GMT 13'
> (FIELD_INTEGRITY_EXCEPTION). see error log for further details.*
> *
> *
> so what should be desired date format for salesforce so that it can be
> inserted.
>
> Thanks,
> Balendra
>
>
>
>
>