2828import java .util .ArrayList ;
2929import java .util .Arrays ;
3030import java .util .Collection ;
31- import java .util .Collections ;
3231import java .util .List ;
3332
3433import org .springframework .core .convert .converter .Converter ;
35- import org .springframework .data .convert .ReadingConverter ;
36- import org .springframework .data .convert .WritingConverter ;
3734import org .springframework .data .redis .core .convert .BinaryConverters .StringBasedConverter ;
38- import org .springframework .util .ClassUtils ;
3935
4036/**
41- * Helper class to register JSR-310 specific {@link Converter} implementations in case the we're running on Java 8 .
37+ * Helper class to register JSR-310 specific {@link Converter} implementations.
4238 *
4339 * @author Mark Paluch
40+ * @author John Blum
4441 */
4542public abstract class Jsr310Converters {
4643
47- private static final boolean JAVA_8_IS_PRESENT = ClassUtils .isPresent ("java.time.LocalDateTime" ,
48- Jsr310Converters .class .getClassLoader ());
49-
5044 /**
5145 * Returns the {@link Converter Converters} to be registered.
52- * <p>
53- * Will only return {@link Converter Converters} in case we're running on Java 8.
5446 *
5547 * @return the {@link Converter Converters} to be registered.
5648 */
5749 public static Collection <Converter <?, ?>> getConvertersToRegister () {
5850
59- if (!JAVA_8_IS_PRESENT ) {
60- return Collections .emptySet ();
61- }
62-
63- List <Converter <?, ?>> converters = new ArrayList <>();
51+ List <Converter <?, ?>> converters = new ArrayList <>(20 );
6452
6553 converters .add (new LocalDateTimeToBytesConverter ());
6654 converters .add (new BytesToLocalDateTimeConverter ());
@@ -88,19 +76,15 @@ public abstract class Jsr310Converters {
8876
8977 public static boolean supports (Class <?> type ) {
9078
91- if (!JAVA_8_IS_PRESENT ) {
92- return false ;
93- }
94-
9579 return Arrays .<Class <?>> asList (LocalDateTime .class , LocalDate .class , LocalTime .class , Instant .class ,
96- ZonedDateTime .class , ZoneId .class , Period .class , Duration .class ).contains (type );
80+ ZonedDateTime .class , ZoneId .class , Period .class , Duration .class , OffsetDateTime .class , OffsetTime .class )
81+ .contains (type );
9782 }
9883
9984 /**
10085 * @author Mark Paluch
10186 * @since 1.7
10287 */
103- @ WritingConverter
10488 static class LocalDateTimeToBytesConverter extends StringBasedConverter implements Converter <LocalDateTime , byte []> {
10589
10690 @ Override
@@ -113,7 +97,6 @@ public byte[] convert(LocalDateTime source) {
11397 * @author Mark Paluch
11498 * @since 1.7
11599 */
116- @ ReadingConverter
117100 static class BytesToLocalDateTimeConverter extends StringBasedConverter implements Converter <byte [], LocalDateTime > {
118101
119102 @ Override
@@ -126,7 +109,6 @@ public LocalDateTime convert(byte[] source) {
126109 * @author Mark Paluch
127110 * @since 1.7
128111 */
129- @ WritingConverter
130112 static class LocalDateToBytesConverter extends StringBasedConverter implements Converter <LocalDate , byte []> {
131113
132114 @ Override
@@ -139,7 +121,6 @@ public byte[] convert(LocalDate source) {
139121 * @author Mark Paluch
140122 * @since 1.7
141123 */
142- @ ReadingConverter
143124 static class BytesToLocalDateConverter extends StringBasedConverter implements Converter <byte [], LocalDate > {
144125
145126 @ Override
@@ -152,7 +133,6 @@ public LocalDate convert(byte[] source) {
152133 * @author Mark Paluch
153134 * @since 1.7
154135 */
155- @ WritingConverter
156136 static class LocalTimeToBytesConverter extends StringBasedConverter implements Converter <LocalTime , byte []> {
157137
158138 @ Override
@@ -165,7 +145,6 @@ public byte[] convert(LocalTime source) {
165145 * @author Mark Paluch
166146 * @since 1.7
167147 */
168- @ ReadingConverter
169148 static class BytesToLocalTimeConverter extends StringBasedConverter implements Converter <byte [], LocalTime > {
170149
171150 @ Override
@@ -178,7 +157,6 @@ public LocalTime convert(byte[] source) {
178157 * @author Mark Paluch
179158 * @since 1.7
180159 */
181- @ WritingConverter
182160 static class ZonedDateTimeToBytesConverter extends StringBasedConverter implements Converter <ZonedDateTime , byte []> {
183161
184162 @ Override
@@ -191,7 +169,6 @@ public byte[] convert(ZonedDateTime source) {
191169 * @author Mark Paluch
192170 * @since 1.7
193171 */
194- @ ReadingConverter
195172 static class BytesToZonedDateTimeConverter extends StringBasedConverter implements Converter <byte [], ZonedDateTime > {
196173
197174 @ Override
@@ -204,7 +181,6 @@ public ZonedDateTime convert(byte[] source) {
204181 * @author Mark Paluch
205182 * @since 1.7
206183 */
207- @ WritingConverter
208184 static class InstantToBytesConverter extends StringBasedConverter implements Converter <Instant , byte []> {
209185
210186 @ Override
@@ -217,7 +193,6 @@ public byte[] convert(Instant source) {
217193 * @author Mark Paluch
218194 * @since 1.7
219195 */
220- @ ReadingConverter
221196 static class BytesToInstantConverter extends StringBasedConverter implements Converter <byte [], Instant > {
222197
223198 @ Override
@@ -230,7 +205,6 @@ public Instant convert(byte[] source) {
230205 * @author Mark Paluch
231206 * @since 1.7
232207 */
233- @ WritingConverter
234208 static class ZoneIdToBytesConverter extends StringBasedConverter implements Converter <ZoneId , byte []> {
235209
236210 @ Override
@@ -243,7 +217,6 @@ public byte[] convert(ZoneId source) {
243217 * @author Mark Paluch
244218 * @since 1.7
245219 */
246- @ ReadingConverter
247220 static class BytesToZoneIdConverter extends StringBasedConverter implements Converter <byte [], ZoneId > {
248221
249222 @ Override
@@ -256,7 +229,6 @@ public ZoneId convert(byte[] source) {
256229 * @author Mark Paluch
257230 * @since 1.7
258231 */
259- @ WritingConverter
260232 static class PeriodToBytesConverter extends StringBasedConverter implements Converter <Period , byte []> {
261233
262234 @ Override
@@ -269,7 +241,6 @@ public byte[] convert(Period source) {
269241 * @author Mark Paluch
270242 * @since 1.7
271243 */
272- @ ReadingConverter
273244 static class BytesToPeriodConverter extends StringBasedConverter implements Converter <byte [], Period > {
274245
275246 @ Override
@@ -282,7 +253,6 @@ public Period convert(byte[] source) {
282253 * @author Mark Paluch
283254 * @since 1.7
284255 */
285- @ WritingConverter
286256 static class DurationToBytesConverter extends StringBasedConverter implements Converter <Duration , byte []> {
287257
288258 @ Override
@@ -295,7 +265,6 @@ public byte[] convert(Duration source) {
295265 * @author Mark Paluch
296266 * @since 1.7
297267 */
298- @ ReadingConverter
299268 static class BytesToDurationConverter extends StringBasedConverter implements Converter <byte [], Duration > {
300269
301270 @ Override
@@ -306,9 +275,10 @@ public Duration convert(byte[] source) {
306275
307276 /**
308277 * @author John Blum
309- * @see java.time.OffsetDateTime
278+ * @since 3.1.3
310279 */
311- static class OffsetDateTimeToBytesConverter extends StringBasedConverter implements Converter <OffsetDateTime , byte []> {
280+ static class OffsetDateTimeToBytesConverter extends StringBasedConverter
281+ implements Converter <OffsetDateTime , byte []> {
312282
313283 @ Override
314284 public byte [] convert (OffsetDateTime source ) {
@@ -318,9 +288,10 @@ public byte[] convert(OffsetDateTime source) {
318288
319289 /**
320290 * @author John Blum
321- * @see java.time.OffsetDateTime
291+ * @since 3.1.3
322292 */
323- static class BytesToOffsetDateTimeConverter extends StringBasedConverter implements Converter <byte [], OffsetDateTime > {
293+ static class BytesToOffsetDateTimeConverter extends StringBasedConverter
294+ implements Converter <byte [], OffsetDateTime > {
324295
325296 @ Override
326297 public OffsetDateTime convert (byte [] source ) {
@@ -330,7 +301,7 @@ public OffsetDateTime convert(byte[] source) {
330301
331302 /**
332303 * @author John Blum
333- * @see java.time.OffsetTime
304+ * @since 3.1.3
334305 */
335306 static class OffsetTimeToBytesConverter extends StringBasedConverter implements Converter <OffsetTime , byte []> {
336307
@@ -342,7 +313,7 @@ public byte[] convert(OffsetTime source) {
342313
343314 /**
344315 * @author John Blum
345- * @see java.time.OffsetTime
316+ * @since 3.1.3
346317 */
347318 static class BytesToOffsetTimeConverter extends StringBasedConverter implements Converter <byte [], OffsetTime > {
348319
0 commit comments