|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2011 the original author or authors. |
|
|
|
|
* Copyright 2002-2012 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,6 @@
@@ -16,8 +16,6 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.format.datetime.joda; |
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Calendar; |
|
|
|
|
import java.util.Date; |
|
|
|
|
@ -34,6 +32,7 @@ import org.joda.time.MutableDateTime;
@@ -34,6 +32,7 @@ import org.joda.time.MutableDateTime;
|
|
|
|
|
import org.junit.After; |
|
|
|
|
import org.junit.Before; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
import org.springframework.beans.MutablePropertyValues; |
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder; |
|
|
|
|
import org.springframework.core.convert.support.DefaultConversionService; |
|
|
|
|
@ -42,6 +41,8 @@ import org.springframework.format.annotation.DateTimeFormat.ISO;
@@ -42,6 +41,8 @@ import org.springframework.format.annotation.DateTimeFormat.ISO;
|
|
|
|
|
import org.springframework.format.support.FormattingConversionService; |
|
|
|
|
import org.springframework.validation.DataBinder; |
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author Keith Donald |
|
|
|
|
* @author Juergen Hoeller |
|
|
|
|
@ -96,7 +97,7 @@ public class JodaTimeFormattingTests {
@@ -96,7 +97,7 @@ public class JodaTimeFormattingTests {
|
|
|
|
|
@Test |
|
|
|
|
public void testBindLocalDateArray() { |
|
|
|
|
MutablePropertyValues propertyValues = new MutablePropertyValues(); |
|
|
|
|
propertyValues.add("localDate", new String[] {"10/31/09"}); |
|
|
|
|
propertyValues.add("localDate", new String[]{"10/31/09"}); |
|
|
|
|
binder.bind(propertyValues); |
|
|
|
|
assertEquals(0, binder.getBindingResult().getErrorCount()); |
|
|
|
|
} |
|
|
|
|
@ -240,6 +241,24 @@ public class JodaTimeFormattingTests {
@@ -240,6 +241,24 @@ public class JodaTimeFormattingTests {
|
|
|
|
|
assertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("date")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testBindDateWithErrorAvoidingDateConstructor() { |
|
|
|
|
MutablePropertyValues propertyValues = new MutablePropertyValues(); |
|
|
|
|
propertyValues.add("date", "Sat, 12 Aug 1995 13:30:00 GMT"); |
|
|
|
|
binder.bind(propertyValues); |
|
|
|
|
assertEquals(1, binder.getBindingResult().getErrorCount()); |
|
|
|
|
assertEquals("Sat, 12 Aug 1995 13:30:00 GMT", binder.getBindingResult().getFieldValue("date")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testBindDateWithoutErrorFallingBackToDateConstructor() { |
|
|
|
|
DataBinder binder = new DataBinder(new JodaTimeBean()); |
|
|
|
|
MutablePropertyValues propertyValues = new MutablePropertyValues(); |
|
|
|
|
propertyValues.add("date", "Sat, 12 Aug 1995 13:30:00 GMT"); |
|
|
|
|
binder.bind(propertyValues); |
|
|
|
|
assertEquals(0, binder.getBindingResult().getErrorCount()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testBindDateAnnotated() { |
|
|
|
|
MutablePropertyValues propertyValues = new MutablePropertyValues(); |
|
|
|
|
|