BigDecimal类
public BigDecimal stringToBigDecimal(String stringBigdecimal) {
if (StringUtils.isBlank(stringBigdecimal)) {
return BigDecimal.ZERO;
}
return new BigDecimal(stringBigdecimal).setScale(2, 4);
}
List
/**
* 字符串值转化为 List<Integer>
*
* @param stringValue 字符串
* @return List<Integer>
*/
public List<Integer> stringSplitToIntegerList(String stringValue) {
if (StringUtils.isBlank(stringValue)) {
return new ArrayList<>();
}
return Arrays.stream(stringValue.split(","))
.filter(StringUtils::isNotBlank)
.map(Integer::valueOf)
.collect(Collectors.toList());
}
/**
* 字符串值转化为 List<Integer>
*
* @param stringValue 字符串
* @return List<Integer>
*/
public List<String> stringSplitToStringList(String stringValue) {
if (StringUtils.isBlank(stringValue)) {
return new ArrayList<>();
}
return Arrays.stream(stringValue.split(","))
.filter(StringUtils::isNotBlank)
.collect(Collectors.toList());
}
/**
* List<Integer> 转化为字符串
*
* @param integerList
* @return
*/
public String integerListToString(List<Integer> integerList) {
if (integerList == null || integerList.isEmpty()) {
return "";
}
String collect = integerList
.stream()
.filter(Objects::nonNull)
.map(String::valueOf)
.collect(Collectors.joining(","));
return Strings.nullToEmpty(collect);
}
/**
* List<String> 转化为字符串
*
* @param integerList
* @return
*/
public String stringListToString(List<String> integerList) {
if (integerList == null || integerList.isEmpty()) {
return "";
}
String collect = integerList
.stream()
.filter(Objects::nonNull)
.collect(Collectors.joining(","));
return Strings.nullToEmpty(collect);
}