Polishing
This commit is contained in:
@@ -27,7 +27,6 @@ import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.springframework.format.Formatter;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -43,6 +42,8 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class DateFormatter implements Formatter<Date> {
|
||||
|
||||
private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
|
||||
|
||||
private static final Map<ISO, String> ISO_PATTERNS;
|
||||
|
||||
static {
|
||||
@@ -176,7 +177,7 @@ public class DateFormatter implements Formatter<Date> {
|
||||
throw new IllegalStateException("Unsupported ISO format " + this.iso);
|
||||
}
|
||||
SimpleDateFormat format = new SimpleDateFormat(pattern);
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
format.setTimeZone(UTC);
|
||||
return format;
|
||||
}
|
||||
if (StringUtils.hasLength(this.stylePattern)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -26,14 +26,17 @@ import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Configures Date formatting for use with Spring.
|
||||
* Configures basic date formatting for use with Spring, primarily for
|
||||
* {@link org.springframework.format.annotation.DateTimeFormat} declarations.
|
||||
* Applies to fields of type {@link Date}, {@link Calendar} and {@code long}.
|
||||
*
|
||||
* <p>Designed for direct instantiation but also exposes the static
|
||||
* {@link #addDateConverters(ConverterRegistry)} utility method for ad hoc use
|
||||
* against any {@code ConverterRegistry} instance.
|
||||
* {@link #addDateConverters(ConverterRegistry)} utility method for
|
||||
* ad-hoc use against any {@code ConverterRegistry} instance.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 3.2
|
||||
* @see org.springframework.format.datetime.standard.DateTimeFormatterRegistrar
|
||||
* @see org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar
|
||||
* @see FormatterRegistrar#registerFormatters
|
||||
*/
|
||||
@@ -43,9 +46,9 @@ 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
|
||||
* Set a global date formatter to register.
|
||||
* <p>If not specified, no general formatter for non-annotated
|
||||
* {@link Date} and {@link Calendar} fields will be registered.
|
||||
*/
|
||||
public void setFormatter(DateFormatter dateFormatter) {
|
||||
Assert.notNull(dateFormatter, "DateFormatter must not be null");
|
||||
|
||||
@@ -30,8 +30,7 @@ import org.springframework.format.Printer;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* Formats fields annotated with the {@link DateTimeFormat} annotation using
|
||||
* a {@link DateFormatter}.
|
||||
* Formats fields annotated with the {@link DateTimeFormat} annotation using a {@link DateFormatter}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 3.2
|
||||
@@ -40,7 +39,6 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
public class DateTimeFormatAnnotationFormatterFactory extends EmbeddedValueResolutionSupport
|
||||
implements AnnotationFormatterFactory<DateTimeFormat> {
|
||||
|
||||
|
||||
private static final Set<Class<?>> FIELD_TYPES;
|
||||
|
||||
static {
|
||||
|
||||
Reference in New Issue
Block a user