File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
spring-core/src/main/java/org/springframework/core/convert/support Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
19
19
import java .nio .charset .Charset ;
20
20
21
21
import org .springframework .core .convert .converter .Converter ;
22
+ import org .springframework .util .StringUtils ;
22
23
23
24
/**
24
25
* Convert a String to a {@link Charset}.
25
26
*
26
27
* @author Stephane Nicoll
28
+ * @author Sam Brannen
27
29
* @since 4.2
28
30
*/
29
31
class StringToCharsetConverter implements Converter <String , Charset > {
30
32
31
33
@ Override
32
34
public Charset convert (String source ) {
35
+ if (StringUtils .hasText (source )) {
36
+ source = source .trim ();
37
+ }
33
38
return Charset .forName (source );
34
39
}
35
40
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
19
19
import java .util .Currency ;
20
20
21
21
import org .springframework .core .convert .converter .Converter ;
22
+ import org .springframework .util .StringUtils ;
22
23
23
24
/**
24
25
* Convert a String to a {@link Currency}.
25
26
*
26
27
* @author Stephane Nicoll
28
+ * @author Sam Brannen
27
29
* @since 4.2
28
30
*/
29
31
class StringToCurrencyConverter implements Converter <String , Currency > {
30
32
31
33
@ Override
32
34
public Currency convert (String source ) {
35
+ if (StringUtils .hasText (source )) {
36
+ source = source .trim ();
37
+ }
33
38
return Currency .getInstance (source );
34
39
}
35
40
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2016 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
25
25
* Convert a String to a {@link TimeZone}.
26
26
*
27
27
* @author Stephane Nicoll
28
+ * @author Sam Brannen
28
29
* @since 4.2
29
30
*/
30
31
class StringToTimeZoneConverter implements Converter <String , TimeZone > {
31
32
32
33
@ Override
33
34
public TimeZone convert (String source ) {
35
+ if (StringUtils .hasText (source )) {
36
+ source = source .trim ();
37
+ }
34
38
return StringUtils .parseTimeZoneString (source );
35
39
}
36
40
You can’t perform that action at this time.
0 commit comments