diff --git a/spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java b/spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java index 8646fa3415c..b09483274c6 100644 --- a/spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java +++ b/spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java @@ -26,7 +26,7 @@ import java.lang.annotation.Target; * Supports formatting by style pattern, ISO date time pattern, or custom format pattern string. * Can be applied to java.util.Date, java.util.Calendar, java.long.Long, or Joda Time fields. *

- * For style-based formatting, set the {@link #style()} attribute to be the style pattern code. + * For style-based formatting, set the {@link #style()} attribute to be the style pattern code. * The first character of the code is the date style, and the second character is the time style. * Specify a character of 'S' for short style, 'M' for medium, 'L' for long, and 'F' for full. * A date or time may be omitted by specifying the style character '-'. @@ -39,7 +39,7 @@ import java.lang.annotation.Target; * When the pattern attribute is specified, it takes precedence over both the style and ISO attribute. * When the iso attribute is specified, if takes precedence over the style attribute. * When no annotation attributes are specified, the default format applied is style-based with a style code of 'SS' (short date, short time). - * + * * @author Keith Donald * @author Juergen Hoeller * @since 3.0 @@ -76,8 +76,8 @@ public @interface DateTimeFormat { * Common ISO date time format patterns. */ public enum ISO { - - /** + + /** * The most common ISO Date Format yyyy-MM-dd e.g. 2000-10-31. */ DATE, @@ -92,7 +92,7 @@ public @interface DateTimeFormat { * The default if no annotation value is specified. */ DATE_TIME, - + /** * Indicates that no ISO-based format pattern should be applied. */ diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaDateTimeFormatAnnotationFormatterFactory.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaDateTimeFormatAnnotationFormatterFactory.java index ad8bbb5beb1..a95745884d9 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaDateTimeFormatAnnotationFormatterFactory.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaDateTimeFormatAnnotationFormatterFactory.java @@ -52,17 +52,17 @@ public class JodaDateTimeFormatAnnotationFormatterFactory private final Set> fieldTypes; private StringValueResolver embeddedValueResolver; - + public JodaDateTimeFormatAnnotationFormatterFactory() { this.fieldTypes = createFieldTypes(); } + public final Set> getFieldTypes() { return this.fieldTypes; } - public void setEmbeddedValueResolver(StringValueResolver resolver) { this.embeddedValueResolver = resolver; } @@ -71,9 +71,8 @@ public class JodaDateTimeFormatAnnotationFormatterFactory return (this.embeddedValueResolver != null ? this.embeddedValueResolver.resolveStringValue(value) : value); } - public Printer getPrinter(DateTimeFormat annotation, Class fieldType) { - DateTimeFormatter formatter = configureDateTimeFormatterFrom(annotation); + DateTimeFormatter formatter = configureDateTimeFormatterFrom(annotation); if (ReadableInstant.class.isAssignableFrom(fieldType)) { return new ReadableInstantPrinter(formatter); } @@ -82,21 +81,21 @@ public class JodaDateTimeFormatAnnotationFormatterFactory } else if (Calendar.class.isAssignableFrom(fieldType)) { // assumes Calendar->ReadableInstant converter is registered - return new ReadableInstantPrinter(formatter); + return new ReadableInstantPrinter(formatter); } else { // assumes Date->Long converter is registered return new MillisecondInstantPrinter(formatter); - } + } } public Parser getParser(DateTimeFormat annotation, Class fieldType) { - return new DateTimeParser(configureDateTimeFormatterFrom(annotation)); + return new DateTimeParser(configureDateTimeFormatterFrom(annotation)); } // internal helpers - /** + /** * Create the set of field types that may be annotated with @DateTimeFormat. * Note: the 3 ReadablePartial concrete types are registered explicitly since addFormatterForFieldType rules exist for each of these types * (if we did not do this, the default byType rules for LocalDate, LocalTime, and LocalDateTime would take precedence over the annotation rule, which is not what we want) @@ -111,9 +110,9 @@ public class JodaDateTimeFormatAnnotationFormatterFactory rawFieldTypes.add(Date.class); rawFieldTypes.add(Calendar.class); rawFieldTypes.add(Long.class); - return Collections.unmodifiableSet(rawFieldTypes); + return Collections.unmodifiableSet(rawFieldTypes); } - + private DateTimeFormatter configureDateTimeFormatterFrom(DateTimeFormat annotation) { if (StringUtils.hasLength(annotation.pattern())) { return forPattern(resolveEmbeddedValue(annotation.pattern())); @@ -143,7 +142,7 @@ public class JodaDateTimeFormatAnnotationFormatterFactory } else { return org.joda.time.format.ISODateTimeFormat.dateTime(); - } + } } } diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java index 05fc3c03dbc..e7d7118fb65 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2012 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. @@ -59,7 +59,7 @@ final class JodaTimeConverters { /** * Used when binding a parsed DateTime to a LocalDate field. - * @see DateTimeParser + * @see DateTimeParser **/ private static class DateTimeToLocalDateConverter implements Converter { public LocalDate convert(DateTime source) { @@ -67,9 +67,9 @@ final class JodaTimeConverters { } } - /** - * Used when binding a parsed DateTime to a LocalTime field. - * @see DateTimeParser + /** + * Used when binding a parsed DateTime to a LocalTime field. + * @see DateTimeParser */ private static class DateTimeToLocalTimeConverter implements Converter { public LocalTime convert(DateTime source) { @@ -77,9 +77,9 @@ final class JodaTimeConverters { } } - /** - * Used when binding a parsed DateTime to a LocalDateTime field. - * @see DateTimeParser + /** + * Used when binding a parsed DateTime to a LocalDateTime field. + * @see DateTimeParser */ private static class DateTimeToLocalDateTimeConverter implements Converter { public LocalDateTime convert(DateTime source) { @@ -87,9 +87,9 @@ final class JodaTimeConverters { } } - /** - * Used when binding a parsed DateTime to a DateMidnight field. - * @see DateTimeParser + /** + * Used when binding a parsed DateTime to a DateMidnight field. + * @see DateTimeParser */ private static class DateTimeToDateMidnightConverter implements Converter { public DateMidnight convert(DateTime source) { @@ -97,9 +97,9 @@ final class JodaTimeConverters { } } - /** - * Used when binding a parsed DateTime to an Instant field. - * @see DateTimeParser + /** + * Used when binding a parsed DateTime to an Instant field. + * @see DateTimeParser */ private static class DateTimeToInstantConverter implements Converter { public Instant convert(DateTime source) { @@ -107,19 +107,19 @@ final class JodaTimeConverters { } } - /** - * Used when binding a parsed DateTime to a MutableDateTime field. - * @see DateTimeParser + /** + * Used when binding a parsed DateTime to a MutableDateTime field. + * @see DateTimeParser */ private static class DateTimeToMutableDateTimeConverter implements Converter { public MutableDateTime convert(DateTime source) { return source.toMutableDateTime(); } } - - /** - * Used when binding a parsed DateTime to a java.util.Date field. - * @see DateTimeParser + + /** + * Used when binding a parsed DateTime to a java.util.Date field. + * @see DateTimeParser */ private static class DateTimeToDateConverter implements Converter { public Date convert(DateTime source) { @@ -127,9 +127,9 @@ final class JodaTimeConverters { } } - /** - * Used when binding a parsed DateTime to a java.util.Calendar field. - * @see DateTimeParser + /** + * Used when binding a parsed DateTime to a java.util.Calendar field. + * @see DateTimeParser */ private static class DateTimeToCalendarConverter implements Converter { public Calendar convert(DateTime source) { @@ -137,9 +137,9 @@ final class JodaTimeConverters { } } - /** - * Used when binding a parsed DateTime to a java.lang.Long field. - * @see DateTimeParser + /** + * Used when binding a parsed DateTime to a java.lang.Long field. + * @see DateTimeParser */ private static class DateTimeToLongConverter implements Converter { public Long convert(DateTime source) { @@ -162,7 +162,7 @@ final class JodaTimeConverters { * Used when printing a java.util.Calendar field with a ReadableInstantPrinter. * @see MillisecondInstantPrinter * @see JodaDateTimeFormatAnnotationFormatterFactory - */ + */ private static class CalendarToReadableInstantConverter implements Converter { public ReadableInstant convert(Calendar source) { return new DateTime(source);