add method

This commit is contained in:
Looly
2021-09-28 00:14:58 +08:00
parent 9642fa8862
commit 1072639f3b
4 changed files with 43 additions and 15 deletions

View File

@@ -1,6 +1,5 @@
package cn.hutool.core.date;
import cn.hutool.core.lang.Console;
import org.junit.Assert;
import org.junit.Test;
@@ -133,10 +132,12 @@ public class DateTimeTest {
Assert.assertEquals(1, date.weekOfYear());
}
@Test
/**
* 严格模式下不允许非常规的数字如秒部分最多5999则报错
*/
@Test(expected = IllegalArgumentException.class)
public void ofTest(){
String a = "2021-09-27 00:00:99";
final DateTime dateTime = new DateTime(a, DatePattern.NORM_DATETIME_FORMAT);
Console.log(dateTime);
new DateTime(a, DatePattern.NORM_DATETIME_FORMAT, false);
}
}