You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dh...@apache.org on 2016/07/26 23:58:42 UTC
[2/2] camel git commit: CAMEL-10090: Fixed Salesforce DateTime
handling in a utility class DateTimeUtils
CAMEL-10090: Fixed Salesforce DateTime handling in a utility class DateTimeUtils
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cace59f0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cace59f0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cace59f0
Branch: refs/heads/master
Commit: cace59f0254e78cd1b1342c3ea1fc70c5dfb9b23
Parents: abb814d
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Tue Jul 26 16:58:28 2016 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jul 26 16:58:28 2016 -0700
----------------------------------------------------------------------
.../salesforce/api/JodaTimeConverter.java | 67 --------------------
.../salesforce/api/utils/DateTimeConverter.java | 56 ++++++++++++++++
.../api/utils/DateTimeDeserializer.java | 43 +++++++++++++
.../salesforce/api/utils/DateTimeModule.java | 31 +++++++++
.../api/utils/DateTimeSerializer.java | 38 +++++++++++
.../salesforce/api/utils/DateTimeUtils.java | 57 +++++++++++++++++
.../internal/datetime/DateTimeDeserializer.java | 52 ---------------
.../internal/datetime/DateTimeModule.java | 31 ---------
.../internal/datetime/DateTimeSerializer.java | 48 --------------
.../internal/processor/XmlRestProcessor.java | 4 +-
10 files changed, 227 insertions(+), 200 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/JodaTimeConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/JodaTimeConverter.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/JodaTimeConverter.java
deleted file mode 100644
index c2c056d..0000000
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/JodaTimeConverter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.salesforce.api;
-
-import java.lang.reflect.Constructor;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeFormatterBuilder;
-
-import com.thoughtworks.xstream.converters.ConversionException;
-import com.thoughtworks.xstream.converters.Converter;
-import com.thoughtworks.xstream.converters.MarshallingContext;
-import com.thoughtworks.xstream.converters.UnmarshallingContext;
-import com.thoughtworks.xstream.io.HierarchicalStreamReader;
-import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
-
-
-/**
- * XStream converter for handling JodaTime fields.
- */
-public class JodaTimeConverter implements Converter {
-
- private final DateTimeFormatter formatter = new DateTimeFormatterBuilder()
- .appendPattern("yyyy-MM-dd'T'HH:mm:ss")
- .appendOffset("+HH:mm", "Z")
- .toFormatter();
-
- @Override
- public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) {
- ZonedDateTime dateTime = (ZonedDateTime) o;
- writer.setValue(formatter.format(dateTime));
- }
-
- @Override
- public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
- String dateTimeStr = reader.getValue();
- Class<?> requiredType = context.getRequiredType();
- try {
- return formatter.parse(dateTimeStr, ZonedDateTime::from);
- } catch (Exception e) {
- throw new ConversionException(
- String.format("Error reading ZonedDateTime from value %s: %s",
- dateTimeStr, e.getMessage()),
- e);
- }
- }
-
- @Override
- public boolean canConvert(Class aClass) {
- return ZonedDateTime.class.isAssignableFrom(aClass);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeConverter.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeConverter.java
new file mode 100644
index 0000000..6722688
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeConverter.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.salesforce.api.utils;
+
+import java.time.ZonedDateTime;
+
+import com.thoughtworks.xstream.converters.ConversionException;
+import com.thoughtworks.xstream.converters.Converter;
+import com.thoughtworks.xstream.converters.MarshallingContext;
+import com.thoughtworks.xstream.converters.UnmarshallingContext;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+
+/**
+ * XStream converter for handling {@link ZonedDateTime} fields.
+ */
+public class DateTimeConverter implements Converter {
+
+ @Override
+ public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) {
+ ZonedDateTime dateTime = (ZonedDateTime) o;
+ writer.setValue(DateTimeUtils.formatDateTime(dateTime));
+ }
+
+ @Override
+ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
+ try {
+ return DateTimeUtils.parseDateTime(reader.getValue());
+ } catch (Exception e) {
+ throw new ConversionException(
+ String.format("Error reading ZonedDateTime from value %s: %s",
+ reader.getValue(), e.getMessage()),
+ e);
+ }
+ }
+
+ @Override
+ public boolean canConvert(Class aClass) {
+ return ZonedDateTime.class.isAssignableFrom(aClass);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeDeserializer.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeDeserializer.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeDeserializer.java
new file mode 100644
index 0000000..a79d137
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeDeserializer.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.salesforce.api.utils;
+
+import java.io.IOException;
+import java.time.ZonedDateTime;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+
+
+public class DateTimeDeserializer extends JsonDeserializer<ZonedDateTime> {
+
+ public DateTimeDeserializer() {
+ super();
+ }
+
+ @Override
+ public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ JsonToken currentToken = jsonParser.getCurrentToken();
+ if (currentToken == JsonToken.VALUE_STRING) {
+ return DateTimeUtils.parseDateTime(jsonParser.getText().trim());
+ }
+ throw deserializationContext.mappingException(getClass());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeModule.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeModule.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeModule.java
new file mode 100644
index 0000000..665a6d8
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeModule.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.salesforce.api.utils;
+
+
+import java.time.ZonedDateTime;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+public class DateTimeModule extends SimpleModule {
+
+ public DateTimeModule() {
+ super();
+ addSerializer(ZonedDateTime.class, new DateTimeSerializer());
+ addDeserializer(ZonedDateTime.class, new DateTimeDeserializer());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeSerializer.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeSerializer.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeSerializer.java
new file mode 100644
index 0000000..ccf936a
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeSerializer.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.salesforce.api.utils;
+
+import java.io.IOException;
+import java.time.ZonedDateTime;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+
+public class DateTimeSerializer extends JsonSerializer<ZonedDateTime> {
+
+ public DateTimeSerializer() {
+ super();
+ }
+
+ @Override
+ public void serialize(ZonedDateTime dateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ jsonGenerator.writeString(DateTimeUtils.formatDateTime(dateTime));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeUtils.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeUtils.java
new file mode 100644
index 0000000..a5c0da2
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/DateTimeUtils.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.salesforce.api.utils;
+
+import java.time.DateTimeException;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.format.DateTimeParseException;
+import java.util.regex.Pattern;
+
+import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME;
+
+/**
+ * Utility class for working with DateTime fields.
+ */
+public abstract class DateTimeUtils {
+
+ private static final Pattern BAD_TZ_PATTERN = Pattern.compile("[+-][0-9]{4}+$");
+
+ private static final DateTimeFormatter ISO_8601_FORMATTER = new DateTimeFormatterBuilder()
+ .parseCaseInsensitive()
+ .append(ISO_LOCAL_DATE_TIME)
+ .appendPattern("[.S][,S]")
+ .appendOffsetId()
+ .toFormatter();
+
+ public static String formatDateTime(ZonedDateTime dateTime) throws DateTimeException {
+ return ISO_8601_FORMATTER.format(dateTime);
+ }
+
+ public static ZonedDateTime parseDateTime(String dateTimeStr) throws DateTimeParseException {
+ return ISO_8601_FORMATTER.parse(normalizeDateTime(dateTimeStr), ZonedDateTime::from);
+ }
+
+ private static String normalizeDateTime(String dateTimeAsString) {
+ if (BAD_TZ_PATTERN.matcher(dateTimeAsString).find()) {
+ int splitAt = dateTimeAsString.length() - 2;
+ dateTimeAsString = dateTimeAsString.substring(0, splitAt) + ":" + dateTimeAsString.substring(splitAt);
+ }
+ return dateTimeAsString;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeDeserializer.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeDeserializer.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeDeserializer.java
deleted file mode 100644
index 39c19c3..0000000
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeDeserializer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.salesforce.internal.datetime;
-
-import java.io.IOException;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeFormatterBuilder;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-
-
-public class DateTimeDeserializer extends JsonDeserializer<ZonedDateTime> {
-
- private final DateTimeFormatter formatter = new DateTimeFormatterBuilder()
- .appendPattern("yyyy-MM-dd'T'HH:mm:ss[.A][,A]")
- .appendOffset("+HH:mm", "Z")
- .toFormatter();
-
- public DateTimeDeserializer() {
- super();
- }
-
- @Override
- public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
- JsonToken currentToken = jsonParser.getCurrentToken();
- if (currentToken == JsonToken.VALUE_STRING) {
- String dateTimeAsString = jsonParser.getText().trim();
- return formatter.parse(dateTimeAsString, ZonedDateTime::from);
- }
- throw deserializationContext.mappingException(getClass());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeModule.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeModule.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeModule.java
deleted file mode 100644
index aec2df8..0000000
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeModule.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.salesforce.internal.datetime;
-
-
-import java.time.ZonedDateTime;
-
-import com.fasterxml.jackson.databind.module.SimpleModule;
-
-public class DateTimeModule extends SimpleModule {
-
- public DateTimeModule() {
- super();
- addSerializer(ZonedDateTime.class, new DateTimeSerializer());
- addDeserializer(ZonedDateTime.class, new DateTimeDeserializer());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeSerializer.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeSerializer.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeSerializer.java
deleted file mode 100644
index 0ad029e..0000000
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/datetime/DateTimeSerializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.salesforce.internal.datetime;
-
-
-
-import java.io.IOException;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeFormatterBuilder;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-
-
-public class DateTimeSerializer extends JsonSerializer<ZonedDateTime> {
-
- private final DateTimeFormatter formatter = new DateTimeFormatterBuilder()
- .appendPattern("yyyy-MM-dd'T'HH:mm:ss")
- .appendOffset("+HH:mm", "Z")
- .toFormatter();
-
- public DateTimeSerializer() {
- super();
- }
-
- @Override
- public void serialize(ZonedDateTime dateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
- jsonGenerator.writeString(formatter.format(dateTime));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cace59f0/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/XmlRestProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/XmlRestProcessor.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/XmlRestProcessor.java
index 4979197..2b4c7af 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/XmlRestProcessor.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/XmlRestProcessor.java
@@ -36,7 +36,7 @@ import org.apache.camel.AsyncCallback;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.component.salesforce.SalesforceEndpoint;
-import org.apache.camel.component.salesforce.api.JodaTimeConverter;
+import org.apache.camel.component.salesforce.api.utils.DateTimeConverter;
import org.apache.camel.component.salesforce.api.SalesforceException;
import org.apache.camel.component.salesforce.api.dto.AbstractDTOBase;
import org.apache.camel.component.salesforce.api.dto.CreateSObjectResult;
@@ -72,7 +72,7 @@ public class XmlRestProcessor extends AbstractRestProcessor {
});
result.ignoreUnknownElements();
XStreamUtils.addDefaultPermissions(result);
- result.registerConverter(new JodaTimeConverter());
+ result.registerConverter(new DateTimeConverter());
return result;
}
};