Changed zone offset to 0.

Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/0129ce4f
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/0129ce4f
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/0129ce4f

Branch: refs/heads/master
Commit: 0129ce4f5788275f29c7baa009b1dfd3b0c95d1e
Parents: c9093b7
Author: kkomyak <const1...@gmail.com>
Authored: Wed Aug 8 13:04:30 2018 +0300
Committer: kkomyak <const1...@gmail.com>
Committed: Wed Aug 8 13:04:30 2018 +0300

----------------------------------------------------------------------
 .../crypto/transformer/value/LocalDateTimeConverter.java    | 9 +++------
 .../transformer/value/LocalDateTimeConverterTest.java       | 4 ++--
 2 files changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/0129ce4f/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverter.java
----------------------------------------------------------------------
diff --git 
a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverter.java
 
b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverter.java
index 6476e60..17e512b 100644
--- 
a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverter.java
+++ 
b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverter.java
@@ -2,7 +2,7 @@ package org.apache.cayenne.crypto.transformer.value;
 
 import java.time.Instant;
 import java.time.LocalDateTime;
-import java.time.ZoneId;
+import java.time.ZoneOffset;
 import java.util.Objects;
 
 /**
@@ -22,15 +22,12 @@ public class LocalDateTimeConverter implements 
BytesConverter<LocalDateTime> {
     public LocalDateTime fromBytes(byte[] bytes) {
 
         return 
LocalDateTime.ofInstant(Instant.ofEpochMilli(longConverter.fromBytes(bytes)),
-                ZoneId.systemDefault());
+                ZoneOffset.ofHours(0));
     }
 
 
     @Override
     public byte[] toBytes(LocalDateTime value) {
-
-        long epochMilli = 
value.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
-
-        return longConverter.toBytes(epochMilli);
+        return 
longConverter.toBytes(value.toInstant(ZoneOffset.ofHours(0)).toEpochMilli());
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/0129ce4f/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java
----------------------------------------------------------------------
diff --git 
a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java
 
b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java
index 9b0e5f2..fc13e9e 100644
--- 
a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java
+++ 
b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java
@@ -18,12 +18,12 @@ public class LocalDateTimeConverterTest {
 
     @Test
     public void testFromBytes() throws ParseException {
-        assertEquals(localDate("2015-01-07 11:00:02"), 
LocalDateTimeConverter.INSTANCE.fromBytes(new byte[]{0, 0, 1, 74, -61, 104, 83, 
-48}));
+        assertEquals(localDate("2015-01-07 11:00:02"), 
LocalDateTimeConverter.INSTANCE.fromBytes(new byte[]{0, 0, 1, 74, -60, 13, 31, 
80}));
     }
 
     @Test
     public void testToBytes() throws ParseException {
-        assertArrayEquals(new byte[]{0, 0, 1, 74, -61, 104, 83, -48},
+        assertArrayEquals(new byte[]{0, 0, 1, 74, -60, 13, 31, 80},
                 LocalDateTimeConverter.INSTANCE.toBytes(localDate("2015-01-07 
11:00:02")));
     }
 }

Reply via email to