mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix null
This commit is contained in:
parent
2be16f97aa
commit
b9738afef9
@ -764,13 +764,16 @@ public class Convert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 半角转全角
|
* 半角转全角,{@code null}返回{@code null}
|
||||||
*
|
*
|
||||||
* @param input String
|
* @param input String
|
||||||
* @param notConvertSet 不替换的字符集合
|
* @param notConvertSet 不替换的字符集合
|
||||||
* @return 全角字符串.
|
* @return 全角字符串,{@code null}返回{@code null}
|
||||||
*/
|
*/
|
||||||
public static String toSBC(final String input, final Set<Character> notConvertSet) {
|
public static String toSBC(final String input, final Set<Character> notConvertSet) {
|
||||||
|
if(StrUtil.isEmpty(input)){
|
||||||
|
return input;
|
||||||
|
}
|
||||||
final char[] c = input.toCharArray();
|
final char[] c = input.toCharArray();
|
||||||
for (int i = 0; i < c.length; i++) {
|
for (int i = 0; i < c.length; i++) {
|
||||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||||
@ -1096,7 +1099,7 @@ public class Convert {
|
|||||||
/**
|
/**
|
||||||
* long转byte数组<br>
|
* long转byte数组<br>
|
||||||
* 默认以小端序转换<br>
|
* 默认以小端序转换<br>
|
||||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||||
*
|
*
|
||||||
* @param longValue long值
|
* @param longValue long值
|
||||||
* @return byte数组
|
* @return byte数组
|
||||||
@ -1109,7 +1112,7 @@ public class Convert {
|
|||||||
/**
|
/**
|
||||||
* byte数组转long<br>
|
* byte数组转long<br>
|
||||||
* 默认以小端序转换<br>
|
* 默认以小端序转换<br>
|
||||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||||
*
|
*
|
||||||
* @param bytes byte数组
|
* @param bytes byte数组
|
||||||
* @return long值
|
* @return long值
|
||||||
|
@ -392,4 +392,16 @@ public class ConvertTest {
|
|||||||
final LocalDate convert = Convert.convert(LocalDate.class, localDateTime);
|
final LocalDate convert = Convert.convert(LocalDate.class, localDateTime);
|
||||||
Assert.assertEquals(localDateTime.toLocalDate(), convert);
|
Assert.assertEquals(localDateTime.toLocalDate(), convert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toSBCTest(){
|
||||||
|
final String s = Convert.toSBC(null);
|
||||||
|
Assert.assertNull(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toDBCTest(){
|
||||||
|
final String s = Convert.toDBC(null);
|
||||||
|
Assert.assertNull(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user