mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
Merge branch 'v5-dev' of gitee.com:dromara/hutool into v5-
dev
This commit is contained in:
@@ -897,4 +897,14 @@ public class DateUtilTest {
|
||||
Assert.assertEquals("2021-07-14 23:59:59", DateUtil.format(date, DatePattern.NORM_DATETIME_FORMAT));
|
||||
Assert.assertEquals("2021-07-14 23:59:59", DateUtil.format(date, DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatNormDateTimeFormatterTest(){
|
||||
String format = DateUtil.format(DateUtil.parse("2021-07-14 10:05:38"), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
Assert.assertEquals("2021-07-14 10:05:38", format);
|
||||
|
||||
format = DateUtil.format(LocalDateTimeUtil.parse("2021-07-14T10:05:38"),
|
||||
"yyyy-MM-dd HH:mm:ss");
|
||||
Assert.assertEquals("2021-07-14 10:05:38", format);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package cn.hutool.core.map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MapBuilderTest {
|
||||
|
||||
@Test
|
||||
public void conditionPutTest() {
|
||||
Map<String, String> map = MapBuilder.<String, String>create()
|
||||
.put(true, "a", "1")
|
||||
.put(false, "b", "2")
|
||||
.put(true, "c", () -> getValue(3))
|
||||
.put(false, "d", () -> getValue(4))
|
||||
.build();
|
||||
|
||||
Assert.assertEquals(map.get("a"), "1");
|
||||
Assert.assertFalse(map.containsKey("b"));
|
||||
Assert.assertEquals(map.get("c"), "3");
|
||||
Assert.assertFalse(map.containsKey("d"));
|
||||
}
|
||||
|
||||
public String getValue(int value) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user