diff --git a/src/main/java/org/springframework/data/redis/core/convert/BinaryConverters.java b/src/main/java/org/springframework/data/redis/core/convert/BinaryConverters.java
index 905d902f0a..5f8a16d63d 100644
--- a/src/main/java/org/springframework/data/redis/core/convert/BinaryConverters.java
+++ b/src/main/java/org/springframework/data/redis/core/convert/BinaryConverters.java
@@ -20,7 +20,9 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Date;
+import java.util.Set;
import java.util.UUID;
import org.springframework.core.convert.converter.Converter;
@@ -46,6 +48,24 @@ final class BinaryConverters {
private BinaryConverters() {}
+ static Collection> getConvertersToRegister() {
+
+ return Set.of(
+ new BinaryConverters.StringToBytesConverter(),
+ new BinaryConverters.BytesToStringConverter(),
+ new BinaryConverters.NumberToBytesConverter(),
+ new BinaryConverters.BytesToNumberConverterFactory(),
+ new BinaryConverters.EnumToBytesConverter(),
+ new BinaryConverters.BytesToEnumConverterFactory(),
+ new BinaryConverters.BooleanToBytesConverter(),
+ new BinaryConverters.BytesToBooleanConverter(),
+ new BinaryConverters.DateToBytesConverter(),
+ new BinaryConverters.BytesToDateConverter(),
+ new BinaryConverters.UuidToBytesConverter(),
+ new BinaryConverters.BytesToUuidConverter()
+ );
+ }
+
/**
* @author Christoph Strobl
* @since 1.7
diff --git a/src/main/java/org/springframework/data/redis/core/convert/Jsr310Converters.java b/src/main/java/org/springframework/data/redis/core/convert/Jsr310Converters.java
index e7a9a464bf..cc6274473b 100644
--- a/src/main/java/org/springframework/data/redis/core/convert/Jsr310Converters.java
+++ b/src/main/java/org/springframework/data/redis/core/convert/Jsr310Converters.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.springframework.data.redis.core.convert;
import java.time.Duration;
@@ -21,6 +20,8 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
import java.time.Period;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@@ -47,9 +48,11 @@ public abstract class Jsr310Converters {
Jsr310Converters.class.getClassLoader());
/**
- * Returns the converters to be registered. Will only return converters in case we're running on Java 8.
+ * Returns the {@link Converter Converters} to be registered.
+ *
+ * Will only return {@link Converter Converters} in case we're running on Java 8.
*
- * @return
+ * @return the {@link Converter Converters} to be registered.
*/
public static Collection> getConvertersToRegister() {
@@ -58,6 +61,7 @@ public abstract class Jsr310Converters {
}
List> converters = new ArrayList<>();
+
converters.add(new LocalDateTimeToBytesConverter());
converters.add(new BytesToLocalDateTimeConverter());
converters.add(new LocalDateToBytesConverter());
@@ -74,6 +78,10 @@ public abstract class Jsr310Converters {
converters.add(new BytesToPeriodConverter());
converters.add(new DurationToBytesConverter());
converters.add(new BytesToDurationConverter());
+ converters.add(new OffsetDateTimeToBytesConverter());
+ converters.add(new BytesToOffsetDateTimeConverter());
+ converters.add(new OffsetTimeToBytesConverter());
+ converters.add(new BytesToOffsetTimeConverter());
return converters;
}
@@ -296,4 +304,51 @@ public Duration convert(byte[] source) {
}
}
+ /**
+ * @author John Blum
+ * @see java.time.OffsetDateTime
+ */
+ static class OffsetDateTimeToBytesConverter extends StringBasedConverter implements Converter {
+
+ @Override
+ public byte[] convert(OffsetDateTime source) {
+ return fromString(source.toString());
+ }
+ }
+
+ /**
+ * @author John Blum
+ * @see java.time.OffsetDateTime
+ */
+ static class BytesToOffsetDateTimeConverter extends StringBasedConverter implements Converter {
+
+ @Override
+ public OffsetDateTime convert(byte[] source) {
+ return OffsetDateTime.parse(toString(source));
+ }
+ }
+
+ /**
+ * @author John Blum
+ * @see java.time.OffsetTime
+ */
+ static class OffsetTimeToBytesConverter extends StringBasedConverter implements Converter {
+
+ @Override
+ public byte[] convert(OffsetTime source) {
+ return fromString(source.toString());
+ }
+ }
+
+ /**
+ * @author John Blum
+ * @see java.time.OffsetTime
+ */
+ static class BytesToOffsetTimeConverter extends StringBasedConverter implements Converter {
+
+ @Override
+ public OffsetTime convert(byte[] source) {
+ return OffsetTime.parse(toString(source));
+ }
+ }
}
diff --git a/src/main/java/org/springframework/data/redis/core/convert/RedisCustomConversions.java b/src/main/java/org/springframework/data/redis/core/convert/RedisCustomConversions.java
index f950d9ca64..267e331fcf 100644
--- a/src/main/java/org/springframework/data/redis/core/convert/RedisCustomConversions.java
+++ b/src/main/java/org/springframework/data/redis/core/convert/RedisCustomConversions.java
@@ -39,18 +39,7 @@ public class RedisCustomConversions extends org.springframework.data.convert.Cus
List