mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复umberUtil.parseNumber对+解析问题
This commit is contained in:
parent
381eec655e
commit
f05d72d74d
@ -12,6 +12,7 @@
|
||||
|
||||
package org.dromara.hutool.core.math;
|
||||
|
||||
import org.dromara.hutool.core.text.CharUtil;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
|
||||
import java.math.BigInteger;
|
||||
@ -287,11 +288,15 @@ public class NumberParser {
|
||||
*
|
||||
* @return 数字
|
||||
*/
|
||||
private Number doParse(final String numberStr) {
|
||||
private Number doParse(String numberStr) {
|
||||
Locale locale = this.locale;
|
||||
if (null == locale) {
|
||||
locale = Locale.getDefault(Locale.Category.FORMAT);
|
||||
}
|
||||
if(StrUtil.startWith(numberStr, CharUtil.PLUS)){
|
||||
// issue#I79VS7
|
||||
numberStr = StrUtil.subSuf(numberStr, 1);
|
||||
}
|
||||
try {
|
||||
final NumberFormat format = NumberFormat.getInstance(locale);
|
||||
if (format instanceof DecimalFormat) {
|
||||
|
@ -281,7 +281,6 @@ public interface WrappedStream<T, S extends WrappedStream<T, S>> extends Stream<
|
||||
@Override
|
||||
default <A> A[] toArray(final IntFunction<A[]> generator) {
|
||||
Objects.requireNonNull(generator);
|
||||
//noinspection SuspiciousToArrayCall
|
||||
return unwrap().toArray(generator);
|
||||
}
|
||||
|
||||
|
28
hutool-core/src/test/java/org/dromara/hutool/core/math/IssueI79VS7Test.java
Executable file
28
hutool-core/src/test/java/org/dromara/hutool/core/math/IssueI79VS7Test.java
Executable file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2023 looly(loolly@aliyun.com)
|
||||
* Hutool is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
package org.dromara.hutool.core.math;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class IssueI79VS7Test {
|
||||
|
||||
@Test
|
||||
void parseNumberTest() {
|
||||
final String value = "+0.003";
|
||||
if(NumberUtil.isNumber(value)) {
|
||||
Assertions.assertEquals(0.003, NumberUtil.parseNumber(value).doubleValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -2,31 +2,16 @@ package org.dromara.hutool.core.stream;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.dromara.hutool.core.collection.CollUtil;
|
||||
import org.dromara.hutool.core.collection.ListUtil;
|
||||
import org.dromara.hutool.core.comparator.CompareUtil;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.lang.Opt;
|
||||
import org.dromara.hutool.core.map.MapUtil;
|
||||
import org.dromara.hutool.core.math.NumberUtil;
|
||||
import org.dromara.hutool.core.util.RandomUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
Loading…
x
Reference in New Issue
Block a user