You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ssatguru <ss...@gmail.com> on 2016/06/25 15:23:37 UTC
camel salesforce component date time issue
camel salesforce component has issues with dates less than or equal to
"November 18th 1883".
These dates are serialized to a format unacceptable to SalesForce.
For example
Date 1800-01-01 is serialized by this component as
1800-01-01T00:00:00.000-05:50:36
Salesforce responds with the following error
{message:'{errors:[{"errorCode":"JSON_PARSER_ERROR","message":"Cannot
deserialize instance of date from VALUE_STRING value
1800-01-01T00:00:00.000-05:50:36 ...
The problem has to do with the seconds in the time zone part (:36 in above
example)
The issue arises because camel salesforce component use the Joda DataTime
library which handles date before "November 18th 1883" in this manner
see here for some discussion on this
https://www.kevinhooke.com/2010/07/23/whats-the-significance-of-nov-18th-1883-to-software-development-in-the-us/
<https://www.kevinhooke.com/2010/07/23/whats-the-significance-of-nov-18th-1883-to-software-development-in-the-us/>
or
http://stackoverflow.com/questions/14282423/why-when-year-is-less-than-1884-it-remove-few-milliseconds
<http://stackoverflow.com/questions/14282423/why-when-year-is-less-than-1884-it-remove-few-milliseconds>
Maybe the salesforce component should convert the date or date time to
milliseconds format rather than the zoned format. Salesforce seems to
accept this format
--
View this message in context: http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel salesforce component date time issue
Posted by arno noordover <an...@gmail.com>.
Hmm, I had the same problem communicating with WCF. I generated classes from
a wsdl containing jodatimes and used a simple conversion to convert this to
a string. I needed to create a special jodatime-format which didn't contain
the seconds part in the time-zone offset.
Although it is technically correct, the xsd datetime don't expect seconds in
de timezone-offset.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399p5784400.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel salesforce component date time issue
Posted by arno noordover <an...@gmail.com>.
Do we help the community (lower footprint) when we switch from jodatime to
java8 zoneddatetime?
Op 27 jun. 2016 8:33 p.m. schreef "arno noordover [via Camel]" <
ml-node+s465427n5784467h39@n5.nabble.com>:
> I decided to implement the raised issue only for 2.18.0, because the
> use-case for old dates in salesforce isn't very clear.
> This decision was made on the fact that 2.18.0 didn't support jodatime at
> all and this was a regression.
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399p5784467.html
> To unsubscribe from camel salesforce component date time issue, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5784399&code=YW5vb3Jkb3ZlckBnbWFpbC5jb218NTc4NDM5OXwxOTYxMzYyMjk2>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399p5784469.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel salesforce component date time issue
Posted by arno noordover <an...@gmail.com>.
I decided to implement the raised issue only for 2.18.0, because the use-case
for old dates in salesforce isn't very clear.
This decision was made on the fact that 2.18.0 didn't support jodatime at
all and this was a regression.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399p5784467.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel salesforce component date time issue
Posted by ssatguru <ss...@gmail.com>.
So the use case for using 1800-01-01in our case was, to some extent,
arbitrary.
Business needed some arbitrary, very old date for some data.
We got around the issue by choosing 1900-01-01 instead.
The problem of course is valid.
One solution could be to pass date in milliseconds (i.e. number of
milliseconds since January 1, 1970, 00:00:00 GMT)
Salesforce seems to accept that. Need to get some verification on that
though.
Here's the relevant Camel SaleForce component code
https://github.com/apache/camel/blob/master/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/JsonRestProcessor.java#L59
<https://github.com/apache/camel/blob/master/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/JsonRestProcessor.java#L59>
replacing
this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
false);
with
this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
true);
results in milliseconds.
Not sure of any other other side effects of this.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399p5784463.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel salesforce component date time issue
Posted by arno noordover <an...@gmail.com>.
I've got an update.
In 2.17.x we use jackson 1.9.12
In 2.18 we use a jackson 2.xx version
2.17.x:
* Normal jodatimes (as in not too old) don't fail;
* Old jodatimes (as in 1-1-1800) fail.
2.18:
* Normal jodatimes fail;
* Old jodatimes fail.
I propose to implement my proposed solution for 2.18 and try to cherry-pick
it in 2.17.
I already created https://issues.apache.org/jira/browse/CAMEL-10090
Who will decide what to do?
--
View this message in context: http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399p5784408.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel salesforce component date time issue
Posted by arno noordover <an...@gmail.com>.
For us the usecase had to do with the default minimal datetime used by WCF
when you don't set a non nullable datetime in C#.
C# fills this datetime with 1-1-0001 and some time-part.
So really not salesforce related of course.
My solution was to provide my own formatter
What the use-case might be here I don't know.
By the way, I'm trying to test this with normal jodatime (say yesterday) and
the 2.18-SNAPSHOT version of salesforce seems to fail with all the datetime
fields.
Of course I'm not sure about my findings because it isn't easy to test
against salesforce.
In my tests I seem to need a jackson SimpleModule:
--
View this message in context: http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399p5784404.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel salesforce component date time issue
Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jun 25, 2016 at 5:23 PM, ssatguru <ss...@gmail.com> wrote:
> camel salesforce component has issues with dates less than or equal to
> "November 18th 1883".
>
I am intrigued to hear what is the use-case is for using dates going
so far back?
And if there is such a problem, has it been reported to jodatime ?
Maybe there is a fix already in a newer version?
> These dates are serialized to a format unacceptable to SalesForce.
>
> For example
>
> Date 1800-01-01 is serialized by this component as
>
> 1800-01-01T00:00:00.000-05:50:36
>
> Salesforce responds with the following error
>
> {message:'{errors:[{"errorCode":"JSON_PARSER_ERROR","message":"Cannot
> deserialize instance of date from VALUE_STRING value
> 1800-01-01T00:00:00.000-05:50:36 ...
>
> The problem has to do with the seconds in the time zone part (:36 in above
> example)
>
> The issue arises because camel salesforce component use the Joda DataTime
> library which handles date before "November 18th 1883" in this manner
>
> see here for some discussion on this
>
> https://www.kevinhooke.com/2010/07/23/whats-the-significance-of-nov-18th-1883-to-software-development-in-the-us/
> <https://www.kevinhooke.com/2010/07/23/whats-the-significance-of-nov-18th-1883-to-software-development-in-the-us/>
>
> or
>
> http://stackoverflow.com/questions/14282423/why-when-year-is-less-than-1884-it-remove-few-milliseconds
> <http://stackoverflow.com/questions/14282423/why-when-year-is-less-than-1884-it-remove-few-milliseconds>
>
> Maybe the salesforce component should convert the date or date time to
> milliseconds format rather than the zoned format. Salesforce seems to
> accept this format
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-salesforce-component-date-time-issue-tp5784399.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2