@@ -76,20 +76,30 @@ public void tearDown() {
76
76
77
77
78
78
@ Test
79
- public void testBindDate () {
79
+ public void testBindLong () {
80
80
MutablePropertyValues propertyValues = new MutablePropertyValues ();
81
- propertyValues .add ("date " , "10/31/09 12:00 PM " );
81
+ propertyValues .add ("millis " , "1256961600 " );
82
82
binder .bind (propertyValues );
83
83
assertEquals (0 , binder .getBindingResult ().getErrorCount ());
84
- assertEquals ("10/31/09 12:00 PM " , binder .getBindingResult ().getFieldValue ("date " ));
84
+ assertEquals ("1256961600 " , binder .getBindingResult ().getFieldValue ("millis " ));
85
85
}
86
86
87
87
@ Test
88
- public void testBindDateArray () {
88
+ public void testBindLongAnnotated () {
89
89
MutablePropertyValues propertyValues = new MutablePropertyValues ();
90
- propertyValues .add ("date " , new String [] { "10/31/09 12:00 PM" } );
90
+ propertyValues .add ("millisAnnotated " , "10/31/09" );
91
91
binder .bind (propertyValues );
92
92
assertEquals (0 , binder .getBindingResult ().getErrorCount ());
93
+ assertEquals ("10/31/09" , binder .getBindingResult ().getFieldValue ("millisAnnotated" ));
94
+ }
95
+
96
+ @ Test
97
+ public void testBindCalendarAnnotated () {
98
+ MutablePropertyValues propertyValues = new MutablePropertyValues ();
99
+ propertyValues .add ("calendarAnnotated" , "10/31/09" );
100
+ binder .bind (propertyValues );
101
+ assertEquals (0 , binder .getBindingResult ().getErrorCount ());
102
+ assertEquals ("10/31/09" , binder .getBindingResult ().getFieldValue ("calendarAnnotated" ));
93
103
}
94
104
95
105
@ Test
@@ -101,6 +111,14 @@ public void testBindDateAnnotated() {
101
111
assertEquals ("10/31/09" , binder .getBindingResult ().getFieldValue ("dateAnnotated" ));
102
112
}
103
113
114
+ @ Test
115
+ public void testBindDateArray () {
116
+ MutablePropertyValues propertyValues = new MutablePropertyValues ();
117
+ propertyValues .add ("dateAnnotated" , new String []{"10/31/09 12:00 PM" });
118
+ binder .bind (propertyValues );
119
+ assertEquals (0 , binder .getBindingResult ().getErrorCount ());
120
+ }
121
+
104
122
@ Test
105
123
public void testBindDateAnnotatedWithError () {
106
124
MutablePropertyValues propertyValues = new MutablePropertyValues ();
@@ -122,39 +140,12 @@ public void testBindDateAnnotatedWithFallbackError() {
122
140
}
123
141
124
142
@ Test
125
- public void testBindCalendar () {
126
- MutablePropertyValues propertyValues = new MutablePropertyValues ();
127
- propertyValues .add ("calendar" , "10/31/09 12:00 PM" );
128
- binder .bind (propertyValues );
129
- assertEquals (0 , binder .getBindingResult ().getErrorCount ());
130
- assertEquals ("10/31/09 12:00 PM" , binder .getBindingResult ().getFieldValue ("calendar" ));
131
- }
132
-
133
- @ Test
134
- public void testBindCalendarAnnotated () {
135
- MutablePropertyValues propertyValues = new MutablePropertyValues ();
136
- propertyValues .add ("calendarAnnotated" , "10/31/09" );
137
- binder .bind (propertyValues );
138
- assertEquals (0 , binder .getBindingResult ().getErrorCount ());
139
- assertEquals ("10/31/09" , binder .getBindingResult ().getFieldValue ("calendarAnnotated" ));
140
- }
141
-
142
- @ Test
143
- public void testBindLong () {
144
- MutablePropertyValues propertyValues = new MutablePropertyValues ();
145
- propertyValues .add ("millis" , "1256961600" );
146
- binder .bind (propertyValues );
147
- assertEquals (0 , binder .getBindingResult ().getErrorCount ());
148
- assertEquals ("1256961600" , binder .getBindingResult ().getFieldValue ("millis" ));
149
- }
150
-
151
- @ Test
152
- public void testBindLongAnnotated () {
143
+ public void testBindDateAnnotatedPattern () {
153
144
MutablePropertyValues propertyValues = new MutablePropertyValues ();
154
- propertyValues .add ("millisAnnotated " , "10/31/09" );
145
+ propertyValues .add ("dateAnnotatedPattern " , "10/31/09 1:05 " );
155
146
binder .bind (propertyValues );
156
147
assertEquals (0 , binder .getBindingResult ().getErrorCount ());
157
- assertEquals ("10/31/09" , binder .getBindingResult ().getFieldValue ("millisAnnotated " ));
148
+ assertEquals ("10/31/09 1:05 " , binder .getBindingResult ().getFieldValue ("dateAnnotatedPattern " ));
158
149
}
159
150
160
151
@ Test
@@ -239,23 +230,17 @@ public void stringToDateWithGlobalFormat() throws Exception {
239
230
@ SuppressWarnings ("unused" )
240
231
private static class SimpleDateBean {
241
232
242
- @ DateTimeFormat
243
- private Date date ;
244
-
245
- @ DateTimeFormat (style ="S-" )
246
- private Date dateAnnotated ;
233
+ private Long millis ;
247
234
248
- @ DateTimeFormat
249
- private Calendar calendar ;
235
+ private Long millisAnnotated ;
250
236
251
237
@ DateTimeFormat (style ="S-" )
252
238
private Calendar calendarAnnotated ;
253
239
254
- private Long millis ;
255
-
256
- private Long millisAnnotated ;
240
+ @ DateTimeFormat (style ="S-" )
241
+ private Date dateAnnotated ;
257
242
258
- @ DateTimeFormat (pattern ="M/d/yy h:mm a " )
243
+ @ DateTimeFormat (pattern ="M/d/yy h:mm" )
259
244
private Date dateAnnotatedPattern ;
260
245
261
246
@ DateTimeFormat (iso =ISO .DATE )
@@ -269,28 +254,21 @@ private static class SimpleDateBean {
269
254
270
255
private final List <SimpleDateBean > children = new ArrayList <SimpleDateBean >();
271
256
272
- public Date getDate () {
273
- return date ;
274
- }
275
-
276
- public void setDate (Date date ) {
277
- this .date = date ;
278
- }
279
-
280
- public Date getDateAnnotated () {
281
- return dateAnnotated ;
257
+ public Long getMillis () {
258
+ return millis ;
282
259
}
283
260
284
- public void setDateAnnotated ( Date dateAnnotated ) {
285
- this .dateAnnotated = dateAnnotated ;
261
+ public void setMillis ( Long millis ) {
262
+ this .millis = millis ;
286
263
}
287
264
288
- public Calendar getCalendar () {
289
- return calendar ;
265
+ @ DateTimeFormat (style ="S-" )
266
+ public Long getMillisAnnotated () {
267
+ return millisAnnotated ;
290
268
}
291
269
292
- public void setCalendar ( Calendar calendar ) {
293
- this .calendar = calendar ;
270
+ public void setMillisAnnotated ( @ DateTimeFormat ( style = "S-" ) Long millisAnnotated ) {
271
+ this .millisAnnotated = millisAnnotated ;
294
272
}
295
273
296
274
public Calendar getCalendarAnnotated () {
@@ -301,21 +279,20 @@ public void setCalendarAnnotated(Calendar calendarAnnotated) {
301
279
this .calendarAnnotated = calendarAnnotated ;
302
280
}
303
281
304
- public Long getMillis () {
305
- return millis ;
282
+ public Date getDateAnnotated () {
283
+ return dateAnnotated ;
306
284
}
307
285
308
- public void setMillis ( Long millis ) {
309
- this .millis = millis ;
286
+ public void setDateAnnotated ( Date dateAnnotated ) {
287
+ this .dateAnnotated = dateAnnotated ;
310
288
}
311
289
312
- @ DateTimeFormat (style ="S-" )
313
- public Long getMillisAnnotated () {
314
- return millisAnnotated ;
290
+ public Date getDateAnnotatedPattern () {
291
+ return dateAnnotatedPattern ;
315
292
}
316
293
317
- public void setMillisAnnotated ( @ DateTimeFormat ( style = "S-" ) Long millisAnnotated ) {
318
- this .millisAnnotated = millisAnnotated ;
294
+ public void setDateAnnotatedPattern ( Date dateAnnotatedPattern ) {
295
+ this .dateAnnotatedPattern = dateAnnotatedPattern ;
319
296
}
320
297
321
298
public Date getIsoDate () {
0 commit comments