Polishing

Issue: SPR-11259
(cherry picked from commit f0d2151)
This commit is contained in:
Juergen Hoeller
2014-01-01 19:24:37 +01:00
parent 57eedf33d6
commit 2e123b01e5
4 changed files with 38 additions and 48 deletions

View File

@@ -59,7 +59,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);
}
@@ -108,7 +108,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private static class CalendarToLongConverter implements Converter<Calendar, Long> {
public Long convert(Calendar source) {
return source.getTime().getTime();
return source.getTimeInMillis();
}
}
@@ -123,10 +123,10 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private static class LongToCalendarConverter implements Converter<Long, Calendar> {
private final DateToCalendarConverter dateToCalendarConverter = new DateToCalendarConverter();
public Calendar convert(Long source) {
return this.dateToCalendarConverter.convert(new Date(source));
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(source);
return calendar;
}
}

View File

@@ -184,7 +184,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),