* Declares that a field should be formatted as a date time.
* Supports formatting by {@link Style} or by pattern string.
* <p>
* For style-based formatting:
* <ul>
* <li>Set <code>dateStyle</code> attribute to specify the style of the <i>date</i> portion of the DateTime.
* <li>Set <code>timeStyle</code> attribute to specify the style of the <i>time</i> portion of the DateTime.
* <li>The default for both dateStyle and timeStyle if not specified is {@link Style#NONE}.
* </ul>
* For pattern-based formatting, set the <code>pattern</code> attribute to be the DateTime pattern, such as <code>yyyy/mm/dd h:mm:ss a</code>.
* <p>
* If no annotation attributes are specified, the default format applied is style-based with dateStyle={@link Style#SHORT} and timeStyle={@link Style#SHORT}.
*
* @author Keith Donald
* @since 3.0
*/
...
...
@@ -51,26 +63,58 @@ public @interface DateTimeFormat {
* Supported DateTimeFormat styles.
*/
publicenumStyle{
/**
* The short format style.
* <br>Example short dateStyle: Locale.US="M/d/yy" e.g. 10/31/2009
* <br>Example short timeStyle: Locale.US="h:mm a" e.g. 1:30 PM
*/
SHORT{
publicStringtoString(){
return"S";
}
},
/**
* The medium format style.
* <br>Example medium dateStyle: Locale.US="MMM d, yyyy" e.g Oct 31, 2009
* <br>Example medium timeStyle: Locale.US="h:mm:ss a" e.g. 1:30:00 PM
*/
MEDIUM{
publicStringtoString(){
return"M";
}
},
/**
* The long format style.
* <br>Example long dateStyle: Locale.US="MMMM d, yyyy" e.g October 31, 2009
* <br>Example long timeStyle: Locale.US="h:mm:ss a z" e.g. 1:30:00 PM Eastern Standard Time
*/
LONG{
publicStringtoString(){
return"L";
}
},
/**
* The full format style.
* <br>Example full dateStyle: Locale.US="EEEE, MMMM d, yyyy" e.g. Saturday, October 31, 2009
* <br>Example full timeStyle: Locale.US="h:mm:ss a z" e.g 1:30:00 PM Eastern Standard Time
*/
FULL{
publicStringtoString(){
return"F";
}
},
/**
* The none format style.
* A dateStyle specified with this value results in date fields such as mm, dd, and yyyy being ignored.
* A timeStyle specified with this value results in time fields such as hh, mm being ignored.
* If both dateStyle and timeStyle are set to this value and the pattern attribute is also not specified,
* a default value for each is selected based on the type of field being annotated.