mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
Merge remote-tracking branch 'origin/v6-dev' into v6-dev
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.dromara.hutool</groupId>
|
||||
<artifactId>hutool-parent</artifactId>
|
||||
<version>6.0.0-M10</version>
|
||||
<version>6.0.0-M11</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hutool-core</artifactId>
|
||||
|
@@ -33,6 +33,7 @@ import org.dromara.hutool.core.util.ObjUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -726,7 +727,7 @@ public class ZipUtil {
|
||||
* Gzip压缩处理
|
||||
*
|
||||
* @param content 被压缩的字符串
|
||||
* @param charset 编码
|
||||
* @param charset 编码 {@link StandardCharsets#UTF_8}、 {@link CharsetUtil#UTF_8}
|
||||
* @return 压缩后的字节流
|
||||
* @throws HutoolException IO异常
|
||||
*/
|
||||
|
@@ -13,7 +13,8 @@
|
||||
package org.dromara.hutool.core.lang.wrapper;
|
||||
|
||||
/**
|
||||
* 简单包装对象
|
||||
* 简单包装对象<br>
|
||||
* 通过继承此类,可以直接使用被包装的对象,用于简化和统一封装。
|
||||
*
|
||||
* @param <T> 被包装对象类型
|
||||
* @author looly
|
||||
|
@@ -297,6 +297,7 @@ public class NumberParser {
|
||||
// issue#I79VS7
|
||||
numberStr = StrUtil.subSuf(numberStr, 1);
|
||||
}
|
||||
|
||||
try {
|
||||
final NumberFormat format = NumberFormat.getInstance(locale);
|
||||
if (format instanceof DecimalFormat) {
|
||||
|
@@ -898,12 +898,12 @@ public class NumberUtil extends NumberValidator {
|
||||
}
|
||||
|
||||
// Float、Double等有精度问题,转换为字符串后再转换
|
||||
return toBigDecimal(number.toString());
|
||||
return new BigDecimal(number.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字转{@link BigDecimal}<br>
|
||||
* null或""或空白符转换为0
|
||||
* null或""或"NaN"或空白符转换为0
|
||||
*
|
||||
* @param numberStr 数字字符串
|
||||
* @return {@link BigDecimal}
|
||||
@@ -927,7 +927,7 @@ public class NumberUtil extends NumberValidator {
|
||||
|
||||
/**
|
||||
* 数字转{@link BigInteger}<br>
|
||||
* null转换为0
|
||||
* null或"NaN"转换为0
|
||||
*
|
||||
* @param number 数字
|
||||
* @return {@link BigInteger}
|
||||
|
@@ -15,6 +15,7 @@ package org.dromara.hutool.core.text;
|
||||
import org.dromara.hutool.core.array.ArrayUtil;
|
||||
import org.dromara.hutool.core.func.FunctionPool;
|
||||
import org.dromara.hutool.core.text.placeholder.StrFormatter;
|
||||
import org.dromara.hutool.core.text.split.SplitUtil;
|
||||
import org.dromara.hutool.core.util.CharsetUtil;
|
||||
|
||||
import java.io.StringReader;
|
||||
@@ -27,6 +28,13 @@ import java.util.Map;
|
||||
* 字符串工具类<br>
|
||||
* 此工具主要针对单个字符串的操作
|
||||
*
|
||||
* <p>本工具类,v6.x进行了拆分。
|
||||
* 字符串分割<strong>split</strong>参考:{@link SplitUtil} <br>
|
||||
* 多字符串判空<strong>hasBlank</strong>参考:{@link ArrayUtil}
|
||||
* </p>
|
||||
* @see SplitUtil#split(CharSequence, CharSequence) 对字符串分割
|
||||
* @see ArrayUtil#hasBlank(CharSequence...) 对多个字符串判空
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
public class StrUtil extends CharSequenceUtil implements StrPool {
|
||||
|
@@ -12,6 +12,8 @@
|
||||
|
||||
package org.dromara.hutool.core.xml;
|
||||
|
||||
import org.dromara.hutool.core.text.CharUtil;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
@@ -30,6 +32,10 @@ public class XmlConstants {
|
||||
* 字符串常量:XML And 符转义 {@code "&" -> "&"}
|
||||
*/
|
||||
public static final String AMP = "&";
|
||||
/**
|
||||
* The Character '&'.
|
||||
*/
|
||||
public static final Character C_AMP = CharUtil.AMP;
|
||||
|
||||
/**
|
||||
* 字符串常量:XML 双引号转义 {@code """ -> "\""}
|
||||
@@ -40,17 +46,41 @@ public class XmlConstants {
|
||||
* 字符串常量:XML 单引号转义 {@code "&apos" -> "'"}
|
||||
*/
|
||||
public static final String APOS = "'";
|
||||
/**
|
||||
* The Character '''.
|
||||
*/
|
||||
public static final Character C_APOS = CharUtil.SINGLE_QUOTE;
|
||||
|
||||
/**
|
||||
* 字符串常量:XML 小于号转义 {@code "<" -> "<"}
|
||||
*/
|
||||
public static final String LT = "<";
|
||||
|
||||
/**
|
||||
* The Character '<'.
|
||||
*/
|
||||
public static final Character C_LT = '<';
|
||||
|
||||
/**
|
||||
* 字符串常量:XML 大于号转义 {@code ">" -> ">"}
|
||||
*/
|
||||
public static final String GT = ">";
|
||||
|
||||
/**
|
||||
* The Character '>'.
|
||||
*/
|
||||
public static final Character C_GT = '>';
|
||||
|
||||
/**
|
||||
* The Character '!'.
|
||||
*/
|
||||
public static final Character C_BANG = '!';
|
||||
|
||||
/**
|
||||
* The Character '?'.
|
||||
*/
|
||||
public static final Character C_QUEST = '?';
|
||||
|
||||
/**
|
||||
* 在XML中无效的字符 正则
|
||||
*/
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package org.dromara.hutool.core.math;
|
||||
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
|
||||
public class Issue3423Test {
|
||||
@Test
|
||||
public void toBigDecimalOfNaNTest() {
|
||||
final BigDecimal naN = NumberUtil.toBigDecimal("NaN");
|
||||
Assertions.assertEquals(BigDecimal.ZERO, naN);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void toBigDecimalOfNaNTest2() throws ParseException {
|
||||
final NumberFormat format = NumberFormat.getInstance();
|
||||
((DecimalFormat) format).setParseBigDecimal(true);
|
||||
final Number naN = format.parse("NaN");
|
||||
Console.log(naN.getClass());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user