Hi Balendra,

When the ColumnType is date, a Date (java.util.Date, or subclass) is
expected. What you're putting there is a String and while we can make
a lot of functions to check for common date patterns, it is
essentially not a true date. Just like when you're dealing with a
database, you don't insert a string into a DATE column, you insert a
proper date object.

So maybe this issue is more of a misunderstanding or an optimization
to support some common date patterns?

Kasper

2013/8/23 Balendra Singh <[email protected]>:
> 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
>>
>>
>>
>>
>>

Reply via email to