fix DateConvert

This commit is contained in:
Looly
2019-12-18 17:34:32 +08:00
parent 7ffdc2c473
commit 0db031e88b
11 changed files with 82 additions and 28 deletions

View File

@@ -3,8 +3,6 @@ package cn.hutool.core.convert;
import org.junit.Assert;
import org.junit.Test;
import cn.hutool.core.convert.Convert;
/**
* 类型转换工具单元测试
* 全角半角转换

View File

@@ -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);

View File

@@ -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";