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 501a874cf1..7f579263d3 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-2021 the original author or authors. + * Copyright 2002-2024 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,6 +25,9 @@ import java.lang.annotation.Target; /** * Declares that a field or method parameter should be formatted as a date or time. * + *
Formatting applies to parsing a date/time object from a string as well as printing a + * date/time object to a string. + * *
Supports formatting by style pattern, ISO date time pattern, or custom format pattern string. * Can be applied to {@link java.util.Date}, {@link java.util.Calendar}, {@link Long} (for * millisecond timestamps) as well as JSR-310 {@code java.time} value types. @@ -33,7 +36,8 @@ import java.lang.annotation.Target; * 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. * The date or time may be omitted by specifying the style character '-' — for example, - * 'M-' specifies a medium format for the date with no time. + * 'M-' specifies a medium format for the date with no time. The supported style pattern codes + * correlate to the enum constants defined in {@link java.time.format.FormatStyle}. * *
For ISO-based formatting, set the {@link #iso} attribute to the desired {@link ISO} format, * such as {@link ISO#DATE}. @@ -65,6 +69,8 @@ import java.lang.annotation.Target; * @author Juergen Hoeller * @author Sam Brannen * @since 3.0 + * @see java.text.DateFormat + * @see java.text.SimpleDateFormat * @see java.time.format.DateTimeFormatter */ @Documented @@ -77,6 +83,8 @@ public @interface DateTimeFormat { *
Defaults to 'SS' for short date, short time. Set this attribute when you * wish to format your field or method parameter in accordance with a common * style other than the default style. + *
See the {@linkplain DateTimeFormat class-level documentation} for further + * details. * @see #fallbackPatterns */ String style() default "SS";