You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/05/07 10:13:20 UTC
[GitHub] [camel] abiuan opened a new pull request #3810: [CAMEL-15024] Add support for ZonedDateTime in camel-bindy
abiuan opened a new pull request #3810:
URL: https://github.com/apache/camel/pull/3810
[ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
[ ] Each commit in the pull request should have a meaningful subject line and body.
[ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
[ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
[ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
Below are the contribution guidelines:
https://github.com/apache/camel/blob/master/CONTRIBUTING.md
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] oscerd commented on a change in pull request #3810: [CAMEL-15024] Add support for ZonedDateTime in camel-bindy
Posted by GitBox <gi...@apache.org>.
oscerd commented on a change in pull request #3810:
URL: https://github.com/apache/camel/pull/3810#discussion_r421395995
##########
File path: components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/date/BindyDatePatternCsvUnmarshallTest.java
##########
@@ -167,7 +171,15 @@ public void setReceivedTime(LocalTime receivedTime) {
this.receivedTime = receivedTime;
}
- public ReturnReason getReturnReason() {
+ public ZonedDateTime getDeletedDateTime() {
Review comment:
Please run the build with the profile sourcecheck enable and fix the warnings you'll see
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] omarsmak commented on a change in pull request #3810: [CAMEL-15024] Add support for ZonedDateTime in camel-bindy
Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #3810:
URL: https://github.com/apache/camel/pull/3810#discussion_r421585122
##########
File path: components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ZonedDateTimeFormatFactory.java
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.dataformat.bindy.format.factories;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Locale;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.PatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class ZonedDateTimeFormatFactory extends AbstractFormatFactory {
+
+ {
+ supportedClasses.add(ZonedDateTime.class);
+ }
+
+ @Override
+ public Format<?> build(FormattingOptions formattingOptions) {
+ return new ZonedDateTimePatternFormat(formattingOptions.getPattern(),
+ formattingOptions.getLocale());
+ }
+
+ private static class ZonedDateTimePatternFormat implements PatternFormat<ZonedDateTime> {
+
+ private String pattern;
+ private Locale locale;
+
+ ZonedDateTimePatternFormat(String pattern/*, String timezone*/, Locale locale) {
+ this.pattern = pattern;
+ this.locale = locale;
+ }
+
+ @Override
+ public String format(ZonedDateTime object) throws Exception {
+ ObjectHelper.notNull(this.pattern, "pattern");
+ return this.getDateFormat().format(object);
+ }
+
+ @Override
+ public ZonedDateTime parse(String string) throws Exception {
+
+ ZonedDateTime date;
+ DateTimeFormatter df = this.getDateFormat();
+
+ ObjectHelper.notNull(this.pattern, "pattern");
+ date = ZonedDateTime.parse(string, df);
Review comment:
I'd change this to initialize `date` directly unless there was another reason perhaps?:
```suggestion
ZonedDateTime date = ZonedDateTime.parse(string, df);
```
##########
File path: components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ZonedDateTimeFormatFactory.java
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.dataformat.bindy.format.factories;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Locale;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.PatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class ZonedDateTimeFormatFactory extends AbstractFormatFactory {
+
+ {
+ supportedClasses.add(ZonedDateTime.class);
+ }
+
+ @Override
+ public Format<?> build(FormattingOptions formattingOptions) {
+ return new ZonedDateTimePatternFormat(formattingOptions.getPattern(),
+ formattingOptions.getLocale());
+ }
+
+ private static class ZonedDateTimePatternFormat implements PatternFormat<ZonedDateTime> {
+
+ private String pattern;
+ private Locale locale;
+
+ ZonedDateTimePatternFormat(String pattern/*, String timezone*/, Locale locale) {
Review comment:
Is it intentional to comment out the string param here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org