提交 7d89de06 编写于 作者: J Juergen Hoeller

Enforce GMT timezone for testBindInstantFromJavaUtilDate

Issue: SPR-16534
上级 15c97b75
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -34,6 +34,7 @@ import java.util.Date; ...@@ -34,6 +34,7 @@ import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
...@@ -359,11 +360,18 @@ public class DateTimeFormattingTests { ...@@ -359,11 +360,18 @@ public class DateTimeFormattingTests {
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void testBindInstantFromJavaUtilDate() { public void testBindInstantFromJavaUtilDate() {
MutablePropertyValues propertyValues = new MutablePropertyValues(); TimeZone defaultZone = TimeZone.getDefault();
propertyValues.add("instant", new Date(109, 9, 31, 12, 0)); TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
binder.bind(propertyValues); try {
assertEquals(0, binder.getBindingResult().getErrorCount()); MutablePropertyValues propertyValues = new MutablePropertyValues();
assertTrue(binder.getBindingResult().getFieldValue("instant").toString().startsWith("2009-10-31")); propertyValues.add("instant", new Date(109, 9, 31, 12, 0));
binder.bind(propertyValues);
assertEquals(0, binder.getBindingResult().getErrorCount());
assertTrue(binder.getBindingResult().getFieldValue("instant").toString().startsWith("2009-10-31"));
}
finally {
TimeZone.setDefault(defaultZone);
}
} }
@Test @Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册