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 8d22560e0f8..d2184e735fe 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 @@ -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. @@ -23,22 +23,26 @@ import java.lang.annotation.Target; /** * Declares that a field should be formatted as a date time. - * Supports formatting by style pattern, ISO date time pattern, or custom format pattern string. - * Can be applied to {@code java.util.Date}, {@code java.util.Calendar}, {@code java.long.Long}, or Joda Time fields. - *
- * For style-based formatting, set the {@link #style()} attribute to be the style pattern code. + * + *
Supports formatting by style pattern, ISO date time pattern, or custom format pattern string.
+ * Can be applied to {@code java.util.Date}, {@code java.util.Calendar}, {@code java.long.Long},
+ * Joda-Time value types; and as of Spring 4 and JDK 8, to JSR-310 java.time types too.
+ *
+ *
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 '-'. - *
- * For ISO-based formatting, set the {@link #iso()} attribute to be the desired {@link ISO} format, such as {@link ISO#DATE}. -
- * For custom formatting, set the {@link #pattern()} attribute to be the DateTime pattern, such as {@code yyyy/MM/dd hh:mm:ss a}. - *
- * Each attribute is mutually exclusive, so only set one attribute per annotation instance (the one most convenient one for your formatting needs). + * + *
For ISO-based formatting, set the {@link #iso()} attribute to be the desired {@link ISO} format, + * such as {@link ISO#DATE}. For custom formatting, set the {@link #pattern()} attribute to be the + * DateTime pattern, such as {@code yyyy/MM/dd hh:mm:ss a}. + * + *
Each attribute is mutually exclusive, so only set one attribute per annotation instance + * (the one most convenient one for your formatting needs). * 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). + * 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 @@ -51,23 +55,24 @@ public @interface DateTimeFormat { /** * The style pattern to use to format the field. - * Defaults to 'SS' for short date time. - * Set this attribute when you wish to format your field in accordance with a common style other than the default style. + *
Defaults to 'SS' for short date time. Set this attribute when you wish to format + * your field in accordance with a common style other than the default style. */ String style() default "SS"; /** * The ISO pattern to use to format the field. * The possible ISO patterns are defined in the {@link ISO} enum. - * Defaults to ISO.NONE, indicating this attribute should be ignored. - * Set this attribute when you wish to format your field in accordance with an ISO date time format. + *
Defaults to {@link ISO#NONE}, indicating this attribute should be ignored. + * Set this attribute when you wish to format your field in accordance with an ISO format. */ ISO iso() default ISO.NONE; /** * The custom pattern to use to format the field. - * Defaults to empty String, indicating no custom pattern String has been specified. - * Set this attribute when you wish to format your field in accordance with a custom date time pattern not represented by a style or ISO format. + *
Defaults to empty String, indicating no custom pattern String has been specified. + * Set this attribute when you wish to format your field in accordance with a custom + * date time pattern not represented by a style or ISO format. */ String pattern() default ""; @@ -78,18 +83,21 @@ public @interface DateTimeFormat { public enum ISO { /** - * The most common ISO Date Format {@code yyyy-MM-dd} e.g. 2000-10-31. + * The most common ISO Date Format {@code yyyy-MM-dd}, + * e.g. 2000-10-31. */ DATE, /** - * The most common ISO Time Format {@code HH:mm:ss.SSSZ} e.g. 01:30:00.000-05:00. + * The most common ISO Time Format {@code HH:mm:ss.SSSZ}, + * e.g. 01:30:00.000-05:00. */ TIME, /** - * The most common ISO DateTime Format {@code yyyy-MM-dd'T'HH:mm:ss.SSSZ} e.g. 2000-10-31 01:30:00.000-05:00. - * The default if no annotation value is specified. + * The most common ISO DateTime Format {@code yyyy-MM-dd'T'HH:mm:ss.SSSZ}, + * e.g. 2000-10-31 01:30:00.000-05:00. + *
This is the default if no annotation value is specified.
*/
DATE_TIME,
diff --git a/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java b/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java
index 365800aba88..b5c660f0236 100644
--- a/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java
+++ b/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java
@@ -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.
@@ -46,7 +46,7 @@ public class DateFormatter implements Formatter If not specified, DateFormat's default style will be used.
@@ -112,7 +121,7 @@ public class DateFormatter implements Formatter
- * Designed for direct instantiation but also exposes the static
+ *
+ * Designed for direct instantiation but also exposes the static
* {@link #addDateConverters(ConverterRegistry)} utility method for ad hoc use
* against any {@code ConverterRegistry} instance.
*
@@ -39,10 +39,20 @@ import org.springframework.util.Assert;
*/
public class DateFormatterRegistrar implements FormatterRegistrar {
-
private DateFormatter dateFormatter;
+ /**
+ * Set the date formatter to register. If not specified no formatter is registered.
+ * This method can be used if global formatter configuration is required.
+ * @param dateFormatter the date formatter
+ */
+ public void setFormatter(DateFormatter dateFormatter) {
+ Assert.notNull(dateFormatter, "DateFormatter must not be null");
+ this.dateFormatter = dateFormatter;
+ }
+
+
public void registerFormatters(FormatterRegistry registry) {
addDateConverters(registry);
registry.addFormatterForFieldAnnotation(new DateTimeFormatAnnotationFormatterFactory());
@@ -55,16 +65,6 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
}
}
- /**
- * Set the date formatter to register. If not specified no formatter is registered.
- * This method can be used if global formatter configuration is required.
- * @param dateFormatter the date formatter
- */
- public void setFormatter(DateFormatter dateFormatter) {
- Assert.notNull(dateFormatter, "DateFormatter must not be null");
- this.dateFormatter = dateFormatter;
- }
-
/**
* Add date converters to the specified registry.
* @param converterRegistry the registry of converters to add to
@@ -80,6 +80,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private static class DateToLongConverter implements Converter Formatters will be created using the defined {@link #setPattern pattern},
+ * {@link #setIso ISO}, and {@link #setStyle style} methods (considered in that order).
*
* @author Phillip Webb
* @author Sam Brannen
* @since 3.2
* @see #createDateTimeFormatter()
* @see #createDateTimeFormatter(DateTimeFormatter)
- * @see #setPattern(String)
+ * @see #setPattern
+ * @see #setStyle
* @see #setIso
- * @see #setStyle(String)
* @see DateTimeFormatterFactoryBean
*/
public class DateTimeFormatterFactory {
+ private String pattern;
+
private ISO iso;
private String style;
- private String pattern;
-
private TimeZone timeZone;
@@ -67,9 +69,50 @@ public class DateTimeFormatterFactory {
/**
- * Create a new {@code DateTimeFormatter} using this factory. If no specific
- * {@link #setStyle(String) style}, {@link #setIso ISO}, or
- * {@link #setPattern(String) pattern} have been defined the
+ * Set the pattern to use to format date values.
+ * @param pattern the format pattern
+ */
+ public void setPattern(String pattern) {
+ this.pattern = pattern;
+ }
+
+ /**
+ * Set the ISO format used to format date values.
+ * @param iso the ISO format
+ */
+ public void setIso(ISO iso) {
+ this.iso = iso;
+ }
+
+ /**
+ * Set the two characters to use to format date values, in Joda-Time style.
+ * The first character is used for the date style; the second is for
+ * the time style. Supported characters are:
+ * If no specific pattern or style has been defined,
* {@link DateTimeFormat#mediumDateTime() medium date time format} will be used.
* @return a new date time formatter
* @see #createDateTimeFormatter(DateTimeFormatter)
@@ -79,21 +122,20 @@ public class DateTimeFormatterFactory {
}
/**
- * Create a new {@code DateTimeFormatter} using this factory. If no specific
- * {@link #setStyle(String) style}, {@link #setIso ISO}, or
- * {@link #setPattern(String) pattern} have been defined the supplied
- * {@code fallbackFormatter} will be used.
- * @param fallbackFormatter the fall-back formatter to use when no specific factory
- * properties have been set (can be {@code null}).
+ * Create a new {@code DateTimeFormatter} using this factory.
+ * If no specific pattern or style has been defined,
+ * the supplied {@code fallbackFormatter} will be used.
+ * @param fallbackFormatter the fall-back formatter to use when no specific
+ * factory properties have been set (can be {@code null}).
* @return a new date time formatter
*/
public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter) {
DateTimeFormatter dateTimeFormatter = null;
- if (StringUtils.hasLength(pattern)) {
- dateTimeFormatter = DateTimeFormat.forPattern(pattern);
+ if (StringUtils.hasLength(this.pattern)) {
+ dateTimeFormatter = DateTimeFormat.forPattern(this.pattern);
}
- else if (iso != null && iso != ISO.NONE) {
- switch (iso) {
+ else if (this.iso != null && this.iso != ISO.NONE) {
+ switch (this.iso) {
case DATE:
dateTimeFormatter = ISODateTimeFormat.date();
break;
@@ -107,11 +149,11 @@ public class DateTimeFormatterFactory {
/* no-op */
break;
default:
- throw new IllegalStateException("Unsupported ISO format: " + iso);
+ throw new IllegalStateException("Unsupported ISO format: " + this.iso);
}
}
- else if (StringUtils.hasLength(style)) {
- dateTimeFormatter = DateTimeFormat.forStyle(style);
+ else if (StringUtils.hasLength(this.style)) {
+ dateTimeFormatter = DateTimeFormat.forStyle(this.style);
}
if (dateTimeFormatter != null && this.timeZone != null) {
@@ -120,44 +162,4 @@ public class DateTimeFormatterFactory {
return (dateTimeFormatter != null ? dateTimeFormatter : fallbackFormatter);
}
- /**
- * Set the {@code TimeZone} to normalize the date values into, if any.
- * @param timeZone the time zone
- */
- public void setTimeZone(TimeZone timeZone) {
- this.timeZone = timeZone;
- }
-
- /**
- * Set the two characters to use to format date values. The first character is used for
- * the date style; the second is for the time style. Supported characters are:
- * This method mimics the styles supported by Joda Time.
- * @param style two characters from the set {"S", "M", "L", "F", "-"}
- */
- public void setStyle(String style) {
- this.style = style;
- }
-
- /**
- * Set the ISO format used to format date values.
- * @param iso the ISO format
- */
- public void setIso(ISO iso) {
- this.iso = iso;
- }
-
- /**
- * Set the pattern to use to format date values.
- * @param pattern the format pattern
- */
- public void setPattern(String pattern) {
- this.pattern = pattern;
- }
}
diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBean.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBean.java
index 8c12e4b317b..20aceca9e12 100644
--- a/spring-context/src/main/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBean.java
+++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBean.java
@@ -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.
@@ -22,15 +22,15 @@ import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
/**
- * {@link FactoryBean} that creates a Joda {@link DateTimeFormatter}. See the
- * {@linkplain DateTimeFormatterFactory base class} for configuration details.
+ * {@link FactoryBean} that creates a Joda-Time {@link DateTimeFormatter}.
+ * See the {@link DateTimeFormatterFactory base class} for configuration details.
*
* @author Phillip Webb
* @author Sam Brannen
* @since 3.2
- * @see #setPattern(String)
- * @see #setIso(org.springframework.format.annotation.DateTimeFormat.ISO)
- * @see #setStyle(String)
+ * @see #setPattern
+ * @see #setIso
+ * @see #setStyle
* @see DateTimeFormatterFactory
*/
public class DateTimeFormatterFactoryBean extends DateTimeFormatterFactory
diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/DateTimeParser.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/DateTimeParser.java
index 92285dffb4c..2918201dbd4 100644
--- a/spring-context/src/main/java/org/springframework/format/datetime/joda/DateTimeParser.java
+++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/DateTimeParser.java
@@ -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.
@@ -25,7 +25,7 @@ import org.joda.time.format.DateTimeFormatter;
import org.springframework.format.Parser;
/**
- * Parses Joda Time {@link DateTime} instances using a {@link DateTimeFormatter}.
+ * Parses Joda {@link DateTime} instances using a {@link DateTimeFormatter}.
*
* @author Keith Donald
* @since 3.0
@@ -34,6 +34,7 @@ public final class DateTimeParser implements Parser A {@code null} property value indicate the user has not specified a setting.
*
* @author Keith Donald
* @since 3.0
@@ -43,8 +45,7 @@ public class JodaTimeContext {
}
/**
- * The user's chronology (calendar system).
- * Null if not specified.
+ * The user's chronology (calendar system), if any.
*/
public Chronology getChronology() {
return this.chronology;
@@ -58,8 +59,7 @@ public class JodaTimeContext {
}
/**
- * The user's timezone.
- * Null if not specified.
+ * The user's timezone, if any.
*/
public DateTimeZone getTimeZone() {
return timeZone;
@@ -67,9 +67,11 @@ public class JodaTimeContext {
/**
- * Gets the Formatter with the this context's settings applied to the base {@code formatter}.
- * @param formatter the base formatter that establishes default formatting rules, generally context independent
- * @return the context DateTimeFormatter
+ * Get the DateTimeFormatter with the this context's settings
+ * applied to the base {@code formatter}.
+ * @param formatter the base formatter that establishes default
+ * formatting rules, generally context-independent
+ * @return the contextual DateTimeFormatter
*/
public DateTimeFormatter getFormatter(DateTimeFormatter formatter) {
if (this.chronology != null) {
diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java
index 85ca71044a6..ffc2b711379 100644
--- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java
+++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java
@@ -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.
@@ -23,7 +23,8 @@ import org.joda.time.format.DateTimeFormatter;
import org.springframework.core.NamedThreadLocal;
/**
- * A holder for a thread-local user {@link JodaTimeContext}.
+ * A holder for a thread-local {@link JodaTimeContext}
+ * with user-specific Joda-Time settings.
*
* @author Keith Donald
* @author Juergen Hoeller
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 b49b6072559..9c966e43468 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
@@ -27,12 +27,14 @@ import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;
import org.joda.time.MutableDateTime;
import org.joda.time.ReadableInstant;
+
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterRegistry;
import org.springframework.format.datetime.DateFormatterRegistrar;
/**
- * Installs lower-level type converters required to integrate Joda Time support into Spring's field formatting system.
+ * Installs lower-level type converters required to integrate
+ * Joda-Time support into Spring's field formatting system.
*
* @author Keith Donald
* @author Phillip Webb
@@ -50,125 +52,111 @@ final class JodaTimeConverters {
registry.addConverter(new DateTimeToLocalTimeConverter());
registry.addConverter(new DateTimeToLocalDateTimeConverter());
registry.addConverter(new DateTimeToDateMidnightConverter());
- registry.addConverter(new DateTimeToInstantConverter());
registry.addConverter(new DateTimeToMutableDateTimeConverter());
+ registry.addConverter(new DateTimeToInstantConverter());
registry.addConverter(new DateTimeToDateConverter());
registry.addConverter(new DateTimeToCalendarConverter());
registry.addConverter(new DateTimeToLongConverter());
- registry.addConverter(new CalendarToReadableInstantConverter());
registry.addConverter(new DateToReadableInstantConverter());
+ registry.addConverter(new CalendarToReadableInstantConverter());
}
- /**
- * Used when binding a parsed DateTime to a LocalDate field.
- * @see DateTimeParser
- **/
private static class DateTimeToLocalDateConverter implements Converter If set to "true", the "dateStyle", "timeStyle" and "dateTimeStyle"
+ * properties are effectively ignored.
+ */
+ public void setUseIsoFormat(boolean useIsoFormat) {
+ this.factories.get(Type.DATE).setIso(useIsoFormat ? ISO.DATE : null);
+ this.factories.get(Type.TIME).setIso(useIsoFormat ? ISO.TIME : null);
+ this.factories.get(Type.DATE_TIME).setIso(useIsoFormat ? ISO.DATE_TIME : null);
+ }
+
/**
* Set the default format style of Joda {@link LocalDate} objects.
* Default is {@link DateTimeFormat#shortDate()}.
*/
public void setDateStyle(String dateStyle) {
- this.factories.get(Type.DATE).setStyle(dateStyle+"-");
+ this.factories.get(Type.DATE).setStyle(dateStyle + "-");
}
/**
@@ -83,7 +99,7 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
* Default is {@link DateTimeFormat#shortTime()}.
*/
public void setTimeStyle(String timeStyle) {
- this.factories.get(Type.TIME).setStyle("-"+timeStyle);
+ this.factories.get(Type.TIME).setStyle("-" + timeStyle);
}
/**
@@ -95,25 +111,14 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
this.factories.get(Type.DATE_TIME).setStyle(dateTimeStyle);
}
- /**
- * Set whether standard ISO formatting should be applied to all Date/Time types.
- * Default is false (no).
- * If set to true, the dateStyle, timeStyle, and dateTimeStyle properties are ignored.
- */
- public void setUseIsoFormat(boolean useIsoFormat) {
- this.factories.get(Type.DATE).setIso(useIsoFormat ? ISO.DATE : null);
- this.factories.get(Type.TIME).setIso(useIsoFormat ? ISO.TIME : null);
- this.factories.get(Type.DATE_TIME).setIso(useIsoFormat ? ISO.DATE_TIME : null);
- }
-
/**
* Set the formatter that will be used for objects representing date values.
* This formatter will be used for the {@link LocalDate} type. When specified
* the {@link #setDateStyle(String) dateStyle} and
* {@link #setUseIsoFormat(boolean) useIsoFormat} properties will be ignored.
* @param formatter the formatter to use
- * @see #setTimeFormatter(DateTimeFormatter)
- * @see #setDateTimeFormatter(DateTimeFormatter)
+ * @see #setTimeFormatter
+ * @see #setDateTimeFormatter
* @since 3.2
*/
public void setDateFormatter(DateTimeFormatter formatter) {
@@ -126,8 +131,8 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
* the {@link #setTimeStyle(String) timeStyle} and
* {@link #setUseIsoFormat(boolean) useIsoFormat} properties will be ignored.
* @param formatter the formatter to use
- * @see #setDateFormatter(DateTimeFormatter)
- * @see #setDateTimeFormatter(DateTimeFormatter)
+ * @see #setDateFormatter
+ * @see #setDateTimeFormatter
* @since 3.2
*/
public void setTimeFormatter(DateTimeFormatter formatter) {
@@ -141,14 +146,15 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
* the {@link #setDateTimeStyle(String) dateTimeStyle} and
* {@link #setUseIsoFormat(boolean) useIsoFormat} properties will be ignored.
* @param formatter the formatter to use
- * @see #setDateFormatter(DateTimeFormatter)
- * @see #setTimeFormatter(DateTimeFormatter)
+ * @see #setDateFormatter
+ * @see #setTimeFormatter
* @since 3.2
*/
public void setDateTimeFormatter(DateTimeFormatter formatter) {
this.formatters.put(Type.DATE_TIME, formatter);
}
+
public void registerFormatters(FormatterRegistry registry) {
JodaTimeConverters.registerConverters(registry);
@@ -176,26 +182,25 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
new DateTimeParser(dateTimeFormatter),
ReadableInstant.class);
- // In order to retain back compatibility we only register Date/Calendar
+ // 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),
Date.class, Calendar.class);
}
- registry.addFormatterForFieldAnnotation(
- new JodaDateTimeFormatAnnotationFormatterFactory());
+ registry.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory());
}
private DateTimeFormatter getFormatter(Type type) {
DateTimeFormatter formatter = this.formatters.get(type);
- if(formatter != null) {
+ if (formatter != null) {
return formatter;
}
DateTimeFormatter fallbackFormatter = getFallbackFormatter(type);
- return this.factories.get(type).createDateTimeFormatter(fallbackFormatter );
+ return this.factories.get(type).createDateTimeFormatter(fallbackFormatter);
}
private DateTimeFormatter getFallbackFormatter(Type type) {
@@ -208,10 +213,10 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
private void addFormatterForFields(FormatterRegistry registry, Printer> printer,
Parser> parser, Class>... fieldTypes) {
+
for (Class> fieldType : fieldTypes) {
registry.addFormatterForFieldType(fieldType, printer, parser);
}
}
- private static enum Type {DATE, TIME, DATE_TIME}
}
diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/MillisecondInstantPrinter.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/MillisecondInstantPrinter.java
index 1cca5b6b739..5c18317c0eb 100644
--- a/spring-context/src/main/java/org/springframework/format/datetime/joda/MillisecondInstantPrinter.java
+++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/MillisecondInstantPrinter.java
@@ -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.
@@ -23,7 +23,7 @@ import org.joda.time.format.DateTimeFormatter;
import org.springframework.format.Printer;
/**
- * Prints Long instances using a {@link DateTimeFormatter}.
+ * Prints Long instances using a Joda {@link DateTimeFormatter}.
*
* @author Keith Donald
* @since 3.0
@@ -32,6 +32,7 @@ public final class MillisecondInstantPrinter implements Printer
- * This method mimics the styles supported by Joda Time.
+ * This method mimics the styles supported by Joda-Time.
* @param stylePattern two characters from the set {"S", "M", "L", "F", "-"}
* @since 3.2
*/
@@ -120,14 +129,6 @@ public class DateFormatter implements Formatter
+ *
+ * @param style two characters from the set {"S", "M", "L", "F", "-"}
+ */
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ /**
+ * Set the {@code TimeZone} to normalize the date values into, if any.
+ * @param timeZone the time zone
+ */
+ public void setTimeZone(TimeZone timeZone) {
+ this.timeZone = timeZone;
+ }
+
+
+ /**
+ * Create a new {@code DateTimeFormatter} using this factory.
+ *
- *
- *