parent
5e00113c65
commit
f0d21510f5
|
@ -60,7 +60,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
|
|||
|
||||
// In order to retain back compatibility we only register Date/Calendar
|
||||
// types when a user defined formatter is specified (see SPR-10105)
|
||||
if(this.dateFormatter != null) {
|
||||
if (this.dateFormatter != null) {
|
||||
registry.addFormatter(this.dateFormatter);
|
||||
registry.addFormatterForFieldType(Calendar.class, this.dateFormatter);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
|
|||
|
||||
@Override
|
||||
public Long convert(Calendar source) {
|
||||
return source.getTime().getTime();
|
||||
return source.getTimeInMillis();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,11 +129,11 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
|
|||
|
||||
private static class LongToCalendarConverter implements Converter<Long, Calendar> {
|
||||
|
||||
private final DateToCalendarConverter dateToCalendarConverter = new DateToCalendarConverter();
|
||||
|
||||
@Override
|
||||
public Calendar convert(Long source) {
|
||||
return this.dateToCalendarConverter.convert(new Date(source));
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(source);
|
||||
return calendar;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
|
|||
|
||||
// In order to retain backwards compatibility we only register Date/Calendar
|
||||
// types when a user defined formatter is specified (see SPR-10105)
|
||||
if( this.formatters.containsKey(Type.DATE_TIME)) {
|
||||
if (this.formatters.containsKey(Type.DATE_TIME)) {
|
||||
addFormatterForFields(registry,
|
||||
new ReadableInstantPrinter(dateTimeFormatter),
|
||||
new DateTimeParser(dateTimeFormatter),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -92,10 +92,10 @@ public class Jsr310DateTimeFormatAnnotationFormatterFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* Factory method used to create a {@link org.joda.time.format.DateTimeFormatter}.
|
||||
* Factory method used to create a {@link DateTimeFormatter}.
|
||||
* @param annotation the format annotation for the field
|
||||
* @param fieldType the type of field
|
||||
* @return a {@link org.joda.time.format.DateTimeFormatter} instance
|
||||
* @return a {@link DateTimeFormatter} instance
|
||||
*/
|
||||
protected DateTimeFormatter getFormatter(DateTimeFormat annotation, Class<?> fieldType) {
|
||||
DateTimeFormatterFactory factory = new DateTimeFormatterFactory();
|
||||
|
|
|
@ -456,6 +456,7 @@ public class GenericConversionService implements ConfigurableConversionService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Manages all converters registered with the service.
|
||||
*/
|
||||
|
@ -614,12 +615,10 @@ public class GenericConversionService implements ConfigurableConversionService {
|
|||
this.converters.addFirst(converter);
|
||||
}
|
||||
|
||||
public GenericConverter getConverter(TypeDescriptor sourceType,
|
||||
TypeDescriptor targetType) {
|
||||
public GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
for (GenericConverter converter : this.converters) {
|
||||
if (!(converter instanceof ConditionalGenericConverter)
|
||||
|| ((ConditionalGenericConverter) converter).matches(sourceType,
|
||||
targetType)) {
|
||||
if (!(converter instanceof ConditionalGenericConverter) ||
|
||||
((ConditionalGenericConverter) converter).matches(sourceType, targetType)) {
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ public class DefaultConversionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testStringToEnumWithSubclss() throws Exception {
|
||||
public void testStringToEnumWithSubclass() throws Exception {
|
||||
assertEquals(SubFoo.BAZ, conversionService.convert("BAZ", SubFoo.BAR.getClass()));
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ public class DefaultConversionTests {
|
|||
}
|
||||
|
||||
public static enum Foo {
|
||||
BAR, BAZ;
|
||||
BAR, BAZ
|
||||
}
|
||||
|
||||
public static enum SubFoo {
|
||||
|
|
Loading…
Reference in New Issue