pc端付款申请以及汉字获取首字母修改
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.yxt.common.base.utils;
|
package com.yxt.common.base.utils;
|
||||||
|
|
||||||
|
import cn.hutool.extra.pinyin.PinyinUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -170,9 +171,11 @@ public class HanZiConverterPinYin {
|
|||||||
firstString = Character.toString(firstChar).toUpperCase();
|
firstString = Character.toString(firstChar).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
String code = hanZiConverterPinYin.getHanZiPY(str);
|
// String code = hanZiConverterPinYin.getHanZiPY(str);
|
||||||
|
String code = PinyinUtil.getFirstLetter(str, "");
|
||||||
StringBuffer buffer = new StringBuffer(code);
|
StringBuffer buffer = new StringBuffer(code);
|
||||||
code = buffer.replace(0, 1, firstString).toString();
|
code = buffer.replace(0, 1, firstString).toString();
|
||||||
|
code = code.toUpperCase();
|
||||||
System.out.println(code);
|
System.out.println(code);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
@@ -180,7 +183,7 @@ public class HanZiConverterPinYin {
|
|||||||
//测试
|
//测试
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
HanZiConverterPinYin hanZiConverterPinYin = new HanZiConverterPinYin();
|
HanZiConverterPinYin hanZiConverterPinYin = new HanZiConverterPinYin();
|
||||||
String str = "仇闪";
|
String str = "王佳琪";
|
||||||
char firstChar = str.toCharArray()[0];
|
char firstChar = str.toCharArray()[0];
|
||||||
String firstString = "";
|
String firstString = "";
|
||||||
if (Character.toString(firstChar).matches("^[\u4e00-\u9fa5]+$")) { // 为中文
|
if (Character.toString(firstChar).matches("^[\u4e00-\u9fa5]+$")) { // 为中文
|
||||||
@@ -196,9 +199,11 @@ public class HanZiConverterPinYin {
|
|||||||
firstString = Character.toString(firstChar).toUpperCase();
|
firstString = Character.toString(firstChar).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
String code = hanZiConverterPinYin.getHanZiPY(str);
|
// String code = hanZiConverterPinYin.getHanZiPY(str);
|
||||||
|
String code = PinyinUtil.getFirstLetter("王佳琪", ""); //c-s
|
||||||
StringBuffer buffer = new StringBuffer(code);
|
StringBuffer buffer = new StringBuffer(code);
|
||||||
code = buffer.replace(0, 1, firstString).toString();
|
code = buffer.replace(0, 1, firstString).toString();
|
||||||
|
code = code.toUpperCase();
|
||||||
System.out.println(code);
|
System.out.println(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user