Repository: apache/dubbo-go-hessian2
Pull request #221 (2020-08-30 12:38:19)

ZoneOffSet & OffsetDateTime & OffsetTime & ZonedDateTime 
<!--  Thanks for sending a pull request! 
-->

**What this PR does**:
java class java.time.ZoneOffset & java.time.OffsetDateTime & java.time.OffsetTime & java.time.ZonedDateTime refer to 
 java8_time.ZoneOffSet & java8_time.OffsetDateTime & java8_time.OffsetTime & java8_time.ZonedDateTime
**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #

**Special notes for your reviewer**:

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note

```


Patch:
diff --git a/java8_time.go b/java8_time.go
index d4a72b1..6d5283f 100644
--- a/java8_time.go
+++ b/java8_time.go
@@ -27,8 +27,13 @@ func init() {
 	RegisterPOJO(&java8_time.Period{Years: 2020, Months: 6, Days: 6})
 	RegisterPOJO(&java8_time.LocalDate{Year: 2020, Month: 6, Day: 6})
 	RegisterPOJO(&java8_time.LocalTime{Hour: 6, Minute: 6, Second: 0, Nano: 0})
-	RegisterPOJO(&java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6}})
+	RegisterPOJO(&java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}})
 	RegisterPOJO(&java8_time.MonthDay{Month: 6, Day: 6})
 	RegisterPOJO(&java8_time.Duration{Second: 0, Nano: 0})
 	RegisterPOJO(&java8_time.Instant{Seconds: 100, Nanos: 0})
+	RegisterPOJO(&java8_time.ZoneOffSet{Seconds: 0})
+	RegisterPOJO(&java8_time.OffsetDateTime{DateTime: java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}}, Offset: java8_time.ZoneOffSet{Seconds: -64800}})
+	RegisterPOJO(&java8_time.OffsetTime{LocalTime: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}, ZoneOffset: java8_time.ZoneOffSet{Seconds: -64800}})
+	RegisterPOJO(&java8_time.ZonedDateTime{DateTime: java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}}, Offset: java8_time.ZoneOffSet{Seconds: 0}, ZoneId: "Z"})
+
 }
diff --git a/java8_time/offset_date_time.go b/java8_time/offset_date_time.go
new file mode 100644
index 0000000..986a804
--- /dev/null
+++ b/java8_time/offset_date_time.go
@@ -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 java8_time
+
+type OffsetDateTime struct {
+	DateTime LocalDateTime `hessian:"dateTime"`
+	Offset   ZoneOffSet    `hessian:"offset"`
+}
+
+func (OffsetDateTime) JavaClassName() string {
+	return "com.alibaba.com.caucho.hessian.io.java8.OffsetDateTimeHandle"
+}
+
+func (OffsetDateTime) Error() string {
+	return "encode OffsetDateTime error"
+}
diff --git a/java8_time/offset_time.go b/java8_time/offset_time.go
new file mode 100644
index 0000000..9adc215
--- /dev/null
+++ b/java8_time/offset_time.go
@@ -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 java8_time
+
+type OffsetTime struct {
+	LocalTime  LocalTime  `hessian:"localTime"`
+	ZoneOffset ZoneOffSet `hessian:"zoneOffset"`
+}
+
+func (OffsetTime) JavaClassName() string {
+	return "com.alibaba.com.caucho.hessian.io.java8.OffsetTimeHandle"
+}
+
+func (OffsetTime) Error() string {
+	return "encode OffsetDateTime error"
+}
diff --git a/java8_time/zone_off_set.go b/java8_time/zone_off_set.go
new file mode 100644
index 0000000..9b2e8a9
--- /dev/null
+++ b/java8_time/zone_off_set.go
@@ -0,0 +1,30 @@
+/*
+ * 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 java8_time
+
+type ZoneOffSet struct {
+	Seconds int32 `hessian:"seconds"`
+}
+
+func (ZoneOffSet) JavaClassName() string {
+	return "com.alibaba.com.caucho.hessian.io.java8.ZoneOffsetHandle"
+}
+
+func (ZoneOffSet) Error() string {
+	return "encode ZoneOffSet error"
+}
diff --git a/java8_time/zoned_date_time.go b/java8_time/zoned_date_time.go
new file mode 100644
index 0000000..2e1eeb2
--- /dev/null
+++ b/java8_time/zoned_date_time.go
@@ -0,0 +1,32 @@
+/*
+ * 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 java8_time
+
+type ZonedDateTime struct {
+	DateTime LocalDateTime `hessian:"dateTime"`
+	Offset   ZoneOffSet    `hessian:"offset"`
+	ZoneId   string        `hessian:"zoneId"`
+}
+
+func (ZonedDateTime) JavaClassName() string {
+	return "com.alibaba.com.caucho.hessian.io.java8.ZonedDateTimeHandle"
+}
+
+func (ZonedDateTime) Error() string {
+	return "encode ZonedDateTime error"
+}


Test patch:
diff --git a/java8_time_test.go b/java8_time_test.go
index 7506291..d9d5985 100644
--- a/java8_time_test.go
+++ b/java8_time_test.go
@@ -26,12 +26,16 @@ func TestJava8Time(t *testing.T) {
 	doTestTime(t, "java8_Year", &java8_time.Year{Year: 2020})
 	doTestTime(t, "java8_LocalDate", &java8_time.LocalDate{Year: 2020, Month: 6, Day: 6})
 	doTestTime(t, "java8_LocalTime", &java8_time.LocalTime{Hour: 6, Minute: 6})
-	doTestTime(t, "java8_LocalDateTime", &java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6}})
+	doTestTime(t, "java8_LocalDateTime", &java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}})
 	doTestTime(t, "java8_MonthDay", &java8_time.MonthDay{Month: 6, Day: 6})
 	doTestTime(t, "java8_Duration", &java8_time.Duration{Second: 0, Nano: 0})
 	doTestTime(t, "java8_Instant", &java8_time.Instant{Seconds: 100, Nanos: 0})
 	doTestTime(t, "java8_YearMonth", &java8_time.YearMonth{Year: 2020, Month: 6})
 	doTestTime(t, "java8_Period", &java8_time.Period{Years: 2020, Months: 6, Days: 6})
+	doTestTime(t, "java8_ZoneOffset", &java8_time.ZoneOffSet{Seconds: 0})
+	doTestTime(t, "java8_OffsetDateTime", &java8_time.OffsetDateTime{DateTime: java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}}, Offset: java8_time.ZoneOffSet{Seconds: -64800}})
+	doTestTime(t, "java8_OffsetTime", &java8_time.OffsetTime{LocalTime: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}, ZoneOffset: java8_time.ZoneOffSet{Seconds: -64800}})
+	doTestTime(t, "java8_ZonedDateTime", &java8_time.ZonedDateTime{DateTime: java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}}, Offset: java8_time.ZoneOffSet{Seconds: 0}, ZoneId: "Z"})
 }
 
 func doTestTime(t *testing.T, method string, expected interface{}) {
diff --git a/test_hessian/src/main/java/test/TestJava8Time.java b/test_hessian/src/main/java/test/TestJava8Time.java
index a4e39f0..779fe5e 100644
--- a/test_hessian/src/main/java/test/TestJava8Time.java
+++ b/test_hessian/src/main/java/test/TestJava8Time.java
@@ -34,7 +34,7 @@ public class TestJava8Time {
     }
 
     public static LocalDateTime java8_LocalDateTime() {
-        return LocalDateTime.of(2020, 6, 6, 6, 6);
+        return LocalDateTime.of(2020, 6, 6, 6, 6, 6, 6);
     }
 
     public static LocalTime java8_LocalTime() {
@@ -71,11 +71,11 @@ public class TestJava8Time {
     }
 
     public static ZoneId java8_ZoneId() {
-        return ZoneId.of("1000");
+        return ZoneId.of("Z");
     }
 
     public static ZoneOffset java8_ZoneOffset() {
-        return ZoneOffset.of("1000");
+        return ZoneOffset.of("Z");
     }
 
 }