mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix DateConvert
This commit is contained in:
@@ -3,8 +3,6 @@ package cn.hutool.core.convert;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
||||
/**
|
||||
* 类型转换工具单元测试
|
||||
* 全角半角转换
|
||||
|
@@ -21,6 +21,14 @@ public class DateConvertTest {
|
||||
Assert.assertEquals(timeLong, value2.getTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDateFromIntTest() {
|
||||
int dateLong = -1497600000;
|
||||
Date value = Convert.toDate(dateLong);
|
||||
Assert.assertNotNull(value);
|
||||
Assert.assertEquals("Mon Dec 15 00:00:00 CST 1969", value.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDateFromLocalDateTimeTest() {
|
||||
LocalDateTime localDateTime = LocalDateTime.parse("2017-05-06T08:30:00", DateTimeFormatter.ISO_DATE_TIME);
|
||||
|
@@ -2,6 +2,7 @@ package cn.hutool.core.date;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.BetweenFormater.Level;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -624,6 +625,14 @@ public class DateUtilTest {
|
||||
Assert.assertEquals("2017-05-06 08:30:00", date.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dateTest2(){
|
||||
// 测试负数日期
|
||||
long dateLong = -1497600000;
|
||||
final DateTime date = DateUtil.date(dateLong);
|
||||
Assert.assertEquals("1969-12-15 00:00:00", date.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ageTest(){
|
||||
String d1 = "2000-02-29";
|
||||
|
Reference in New Issue
Block a user