Merge branch '5.3.x'
This commit is contained in:
commit
613aac5009
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -19,17 +19,22 @@ package org.springframework.core.convert.support;
|
|||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Convert a String to a {@link Charset}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
* @since 4.2
|
||||
*/
|
||||
class StringToCharsetConverter implements Converter<String, Charset> {
|
||||
|
||||
@Override
|
||||
public Charset convert(String source) {
|
||||
if (StringUtils.hasText(source)) {
|
||||
source = source.trim();
|
||||
}
|
||||
return Charset.forName(source);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -19,17 +19,22 @@ package org.springframework.core.convert.support;
|
|||
import java.util.Currency;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Convert a String to a {@link Currency}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
* @since 4.2
|
||||
*/
|
||||
class StringToCurrencyConverter implements Converter<String, Currency> {
|
||||
|
||||
@Override
|
||||
public Currency convert(String source) {
|
||||
if (StringUtils.hasText(source)) {
|
||||
source = source.trim();
|
||||
}
|
||||
return Currency.getInstance(source);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -25,12 +25,16 @@ import org.springframework.util.StringUtils;
|
|||
* Convert a String to a {@link TimeZone}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
* @since 4.2
|
||||
*/
|
||||
class StringToTimeZoneConverter implements Converter<String, TimeZone> {
|
||||
|
||||
@Override
|
||||
public TimeZone convert(String source) {
|
||||
if (StringUtils.hasText(source)) {
|
||||
source = source.trim();
|
||||
}
|
||||
return StringUtils.parseTimeZoneString(source);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue