|
|
|
|
@ -30,7 +30,6 @@ import java.time.format.DateTimeFormatter;
@@ -30,7 +30,6 @@ import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Collection; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
@ -38,7 +37,6 @@ import javax.annotation.Nonnull;
@@ -38,7 +37,6 @@ import javax.annotation.Nonnull;
|
|
|
|
|
|
|
|
|
|
import org.springframework.core.convert.converter.Converter; |
|
|
|
|
import org.springframework.lang.NonNull; |
|
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Helper class to register JSR-310 specific {@link Converter} implementations in case the we're running on Java 8. |
|
|
|
|
@ -51,8 +49,6 @@ import org.springframework.util.ClassUtils;
@@ -51,8 +49,6 @@ import org.springframework.util.ClassUtils;
|
|
|
|
|
*/ |
|
|
|
|
public abstract class Jsr310Converters { |
|
|
|
|
|
|
|
|
|
private static final boolean JAVA_8_IS_PRESENT = ClassUtils.isPresent("java.time.LocalDateTime", |
|
|
|
|
Jsr310Converters.class.getClassLoader()); |
|
|
|
|
private static final List<Class<?>> CLASSES = Arrays.asList(LocalDateTime.class, LocalDate.class, LocalTime.class, |
|
|
|
|
Instant.class, ZoneId.class, Duration.class, Period.class); |
|
|
|
|
|
|
|
|
|
@ -63,10 +59,6 @@ public abstract class Jsr310Converters {
@@ -63,10 +59,6 @@ public abstract class Jsr310Converters {
|
|
|
|
|
*/ |
|
|
|
|
public static Collection<Converter<?, ?>> getConvertersToRegister() { |
|
|
|
|
|
|
|
|
|
if (!JAVA_8_IS_PRESENT) { |
|
|
|
|
return Collections.emptySet(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Converter<?, ?>> converters = new ArrayList<>(); |
|
|
|
|
converters.add(DateToLocalDateTimeConverter.INSTANCE); |
|
|
|
|
converters.add(LocalDateTimeToDateConverter.INSTANCE); |
|
|
|
|
@ -93,10 +85,6 @@ public abstract class Jsr310Converters {
@@ -93,10 +85,6 @@ public abstract class Jsr310Converters {
|
|
|
|
|
|
|
|
|
|
public static boolean supports(Class<?> type) { |
|
|
|
|
|
|
|
|
|
if (!JAVA_8_IS_PRESENT) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return CLASSES.contains(type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|