字符串长度处理
This commit is contained in:
parent
d25f17782b
commit
b19e4043cd
@ -147,6 +147,20 @@ public class StringUtils extends StrUtil {
|
||||
return str.concat(appendStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切割字符串
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param length 长度
|
||||
* @return 处理后的字符串
|
||||
*/
|
||||
public static String sub(String str, Integer length) {
|
||||
if (str.length() < length) {
|
||||
return str;
|
||||
}
|
||||
return str.substring(0, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤特殊字符串
|
||||
*
|
||||
|
@ -49,10 +49,6 @@ public class CashierParam {
|
||||
if (StringUtils.isEmpty(detail)) {
|
||||
return "清单详细";
|
||||
}
|
||||
//对参数长度进行限制
|
||||
if (!StringUtils.isEmpty(detail) && detail.length() > MAX_DETAIL_LENGTH) {
|
||||
detail = detail.substring(30);
|
||||
}
|
||||
return StringUtils.filterSpecialChart(detail);
|
||||
return StringUtils.filterSpecialChart(StringUtils.sub(detail, 30));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user