@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2016 the original author or authors .
* Copyright 2002 - 2018 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 .
@ -62,12 +62,12 @@ public class JodaTimeFormattingTests {
@@ -62,12 +62,12 @@ public class JodaTimeFormattingTests {
@Before
public void setU p ( ) {
public void setu p ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
}
private void setU p ( JodaTimeFormatterRegistrar registrar ) {
private void setu p ( JodaTimeFormatterRegistrar registrar ) {
conversionService = new FormattingConversionService ( ) ;
DefaultConversionService . addDefaultConverters ( conversionService ) ;
registrar . registerFormatters ( conversionService ) ;
@ -84,7 +84,7 @@ public class JodaTimeFormattingTests {
@@ -84,7 +84,7 @@ public class JodaTimeFormattingTests {
}
@After
public void tearDown ( ) {
public void cleanup ( ) {
LocaleContextHolder . setLocale ( null ) ;
JodaTimeContextHolder . setJodaTimeContext ( null ) ;
}
@ -108,10 +108,10 @@ public class JodaTimeFormattingTests {
@@ -108,10 +108,10 @@ public class JodaTimeFormattingTests {
}
@Test
public void testBindLocalDateWithSpecificStyle ( ) throws Exception {
public void testBindLocalDateWithSpecificStyle ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
registrar . setDateStyle ( "L" ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDate" , "October 31, 2009" ) ;
binder . bind ( propertyValues ) ;
@ -120,10 +120,10 @@ public class JodaTimeFormattingTests {
@@ -120,10 +120,10 @@ public class JodaTimeFormattingTests {
}
@Test
public void testBindLocalDateWithSpecificFormatter ( ) throws Exception {
public void testBindLocalDateWithSpecificFormatter ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
registrar . setDateFormatter ( org . joda . time . format . DateTimeFormat . forPattern ( "yyyyMMdd" ) ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDate" , "20091031" ) ;
binder . bind ( propertyValues ) ;
@ -196,10 +196,10 @@ public class JodaTimeFormattingTests {
@@ -196,10 +196,10 @@ public class JodaTimeFormattingTests {
}
@Test
public void testBindLocalTimeWithSpecificStyle ( ) throws Exception {
public void testBindLocalTimeWithSpecificStyle ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
registrar . setTimeStyle ( "M" ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localTime" , "12:00:00 PM" ) ;
binder . bind ( propertyValues ) ;
@ -208,10 +208,10 @@ public class JodaTimeFormattingTests {
@@ -208,10 +208,10 @@ public class JodaTimeFormattingTests {
}
@Test
public void testBindLocalTimeWithSpecificFormatter ( ) throws Exception {
public void testBindLocalTimeWithSpecificFormatter ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
registrar . setTimeFormatter ( org . joda . time . format . DateTimeFormat . forPattern ( "HHmmss" ) ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localTime" , "130000" ) ;
binder . bind ( propertyValues ) ;
@ -261,10 +261,10 @@ public class JodaTimeFormattingTests {
@@ -261,10 +261,10 @@ public class JodaTimeFormattingTests {
}
@Test
public void testBindDateTimeWithSpecificStyle ( ) throws Exception {
public void testBindDateTimeWithSpecificStyle ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
registrar . setDateTimeStyle ( "MM" ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDateTime" , new LocalDateTime ( 2009 , 10 , 31 , 12 , 0 ) ) ;
binder . bind ( propertyValues ) ;
@ -275,10 +275,10 @@ public class JodaTimeFormattingTests {
@@ -275,10 +275,10 @@ public class JodaTimeFormattingTests {
}
@Test
public void testBindDateTimeISO ( ) throws Exception {
public void testBindDateTimeISO ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
registrar . setUseIsoFormat ( true ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "dateTime" , "2009-10-31T12:00:00.000Z" ) ;
binder . bind ( propertyValues ) ;
@ -287,10 +287,10 @@ public class JodaTimeFormattingTests {
@@ -287,10 +287,10 @@ public class JodaTimeFormattingTests {
}
@Test
public void testBindDateTimeWithSpecificFormatter ( ) throws Exception {
public void testBindDateTimeWithSpecificFormatter ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
registrar . setDateTimeFormatter ( org . joda . time . format . DateTimeFormat . forPattern ( "yyyyMMddHHmmss" ) ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "dateTime" , "20091031130000" ) ;
binder . bind ( propertyValues ) ;
@ -435,33 +435,31 @@ public class JodaTimeFormattingTests {
@@ -435,33 +435,31 @@ public class JodaTimeFormattingTests {
}
@Test
public void dateToStringWithFormat ( ) throws Exception {
public void dateToStringWithFormat ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
registrar . setDateTimeFormatter ( org . joda . time . format . DateTimeFormat . shortDateTime ( ) ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
Date date = new Date ( ) ;
Object actual = this . conversionService . convert ( date , TypeDescriptor . valueOf ( Date . class ) , TypeDescriptor . valueOf ( String . class ) ) ;
String expected = JodaTimeContextHolder . getFormatter ( org . joda . time . format . DateTimeFormat . shortDateTime ( ) , Locale . US ) . print ( new DateTime ( date ) ) ;
assertEquals ( expected , actual ) ;
}
@Test
@Test // SPR-10105
@SuppressWarnings ( "deprecation" )
public void stringToDateWithoutGlobalFormat ( ) throws Exception {
// SPR-10105
public void stringToDateWithoutGlobalFormat ( ) {
String string = "Sat, 12 Aug 1995 13:30:00 GM" ;
Date date = this . conversionService . convert ( string , Date . class ) ;
assertThat ( date , equalTo ( new Date ( string ) ) ) ;
}
@Test
public void stringToDateWithGlobalFormat ( ) throws Exception {
// SPR-10105
@Test // SPR-10105
public void stringToDateWithGlobalFormat ( ) {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar ( ) ;
DateTimeFormatterFactory factory = new DateTimeFormatterFactory ( ) ;
factory . setIso ( ISO . DATE_TIME ) ;
registrar . setDateTimeFormatter ( factory . createDateTimeFormatter ( ) ) ;
setU p ( registrar ) ;
setu p ( registrar ) ;
// This is a format that cannot be parsed by new Date(String)
String string = "2009-10-31T07:00:00.000-05:00" ;
Date date = this . conversionService . convert ( string , Date . class ) ;