|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2009 the original author or authors. |
|
|
|
|
* Copyright 2002-2010 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. |
|
|
|
@ -16,8 +16,10 @@
@@ -16,8 +16,10 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.format.datetime.joda; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Calendar; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
import org.joda.time.DateTime; |
|
|
|
@ -55,7 +57,9 @@ public class JodaTimeFormattingTests {
@@ -55,7 +57,9 @@ public class JodaTimeFormattingTests {
|
|
|
|
|
JodaTimeFormattingConfigurer configurer = new JodaTimeFormattingConfigurer(); |
|
|
|
|
configurer.installJodaTimeFormatting(conversionService); |
|
|
|
|
|
|
|
|
|
binder = new DataBinder(new JodaTimeBean()); |
|
|
|
|
JodaTimeBean bean = new JodaTimeBean(); |
|
|
|
|
bean.getChildren().add(new JodaTimeBean()); |
|
|
|
|
binder = new DataBinder(bean); |
|
|
|
|
binder.setConversionService(conversionService); |
|
|
|
|
|
|
|
|
|
LocaleContextHolder.setLocale(Locale.US); |
|
|
|
@ -104,6 +108,15 @@ public class JodaTimeFormattingTests {
@@ -104,6 +108,15 @@ public class JodaTimeFormattingTests {
|
|
|
|
|
assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testBindNestedLocalDateAnnotated() { |
|
|
|
|
MutablePropertyValues propertyValues = new MutablePropertyValues(); |
|
|
|
|
propertyValues.add("children[0].localDateAnnotated", "Oct 31, 2009"); |
|
|
|
|
binder.bind(propertyValues); |
|
|
|
|
assertEquals(0, binder.getBindingResult().getErrorCount()); |
|
|
|
|
assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("children[0].localDateAnnotated")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testBindLocalDateAnnotatedWithDirectFieldAccess() { |
|
|
|
|
binder.initDirectFieldAccess(); |
|
|
|
@ -337,6 +350,8 @@ public class JodaTimeFormattingTests {
@@ -337,6 +350,8 @@ public class JodaTimeFormattingTests {
|
|
|
|
|
@DateTimeFormat(iso=ISO.DATE_TIME) |
|
|
|
|
private DateTime isoDateTime; |
|
|
|
|
|
|
|
|
|
private final List<JodaTimeBean> children = new ArrayList<JodaTimeBean>(); |
|
|
|
|
|
|
|
|
|
public LocalDate getLocalDate() { |
|
|
|
|
return localDate; |
|
|
|
|
} |
|
|
|
@ -497,5 +512,9 @@ public class JodaTimeFormattingTests {
@@ -497,5 +512,9 @@ public class JodaTimeFormattingTests {
|
|
|
|
|
this.isoDateTime = isoDateTime; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<JodaTimeBean> getChildren() { |
|
|
|
|
return children; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|