mirror of
https://gitee.com/dromara/hutool.git
synced 2025-11-24 08:33:22 +08:00
Mail.buildContent改进,正文部分总在最前(issue#4072@Github)gts
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.41(2025-09-13)
|
||||
# 5.8.41(2025-09-16)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 增加`WeakKeyValueConcurrentMap`及其关联类,同时废弃`WeakConcurrentMap`并替换(issue#4039@Github)
|
||||
@@ -16,6 +16,7 @@
|
||||
* 【core 】 `NumberUtil.pow`增加重载,支持指数自定义保留位数(pr#4052@Github)
|
||||
* 【core 】 `NumberUtil.isPrimes`优化判断(pr#4058@Github)
|
||||
* 【extra 】 `Mail.buildContent`改进,正文部分总在最前(issue#4072@Github)
|
||||
* 【core 】 `DataSizeUtil`改进,兼容`GiB`等单位名称(issue#ICXXVF@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【core 】 修复`ReflectUtil`中因class和Method关联导致的缓存无法回收问题(issue#4039@Github)
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class DataSize implements Comparable<DataSize> {
|
||||
/**
|
||||
* The pattern for parsing.
|
||||
*/
|
||||
private static final Pattern PATTERN = Pattern.compile("^([+-]?\\d+(\\.\\d+)?)([a-zA-Z]{0,2})$");
|
||||
private static final Pattern PATTERN = Pattern.compile("^([+-]?\\d+(\\.\\d+)?)([a-zA-Z]{0,3})$");
|
||||
|
||||
/**
|
||||
* Bytes per Kilobyte(KB).
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.io.unit;
|
||||
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
@@ -75,11 +76,16 @@ public enum DataUnit {
|
||||
/**
|
||||
* 通过后缀返回对应的 DataUnit
|
||||
*
|
||||
* @param suffix 单位后缀
|
||||
* @return 匹配到的{@link DataUnit}
|
||||
* @param suffix 单位后缀,如KB、GB、GiB等
|
||||
* @return 匹配到的{@code DataUnit}
|
||||
* @throws IllegalArgumentException 后缀无法识别报错
|
||||
*/
|
||||
public static DataUnit fromSuffix(String suffix) {
|
||||
// issue#ICXXVF 兼容KiB、MiB、GiB
|
||||
if(StrUtil.length(suffix) == 3 && CharUtil.equals(suffix.charAt(1), 'i', true)){
|
||||
suffix = new String(new char[]{suffix.charAt(0), suffix.charAt(2)});
|
||||
}
|
||||
|
||||
for (DataUnit candidate : values()) {
|
||||
// 支持类似于 3MB,3M,3m等写法
|
||||
if (StrUtil.startWithIgnoreCase(candidate.suffix, suffix)) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.io.unit;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -80,4 +81,10 @@ public class DataSizeUtilTest {
|
||||
final long bytes = DataSize.parse(size).toBytes();
|
||||
assertEquals(10244587, bytes);
|
||||
}
|
||||
|
||||
@Test
|
||||
void issueICXXVFTest(){
|
||||
final long parse = DataSizeUtil.parse("279.40GiB");
|
||||
Assertions.assertEquals(300003465625L, parse);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user