Hi all, Looked into this together with Balendra on Skype, and we had a few findings:
* The SF module is working fine, as long as you pass a java.util.Date. So the two issues created today should be cancelled since they are assuming a wrong behaviour. But ... * We don't have any automatic conversion of strings to dates in place, which may be useful, but it should be a separate story I think. And preferrably it should not be Salesforce-specific, but something we can in a more generic fashion. I'll post a issue in JIRA to address this shortly. * In the salesforce module we always convert incoming Date values using a SimpleDateFormat with the UTC timezone. This is because SF saves the dates in UTC, so we have to ensure we don't wrongly send a date in the wrong format. All well. But a problem is that we also do this (apply timezone) for DATE columns, which are columns that don't have any time-of-day information (like a birthdate). In such scenarios we should not apply a timezone since it may change the actual date that we're submitting to SF. This is a bug which I'll post a patch for shortly. Regards, Kasper 2013/8/23 Kasper Sørensen <[email protected]>: > 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 >>> >>> >>> >>> >>>
