mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add constructor
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.collection;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.lang.Editor;
|
||||
import cn.hutool.core.lang.Filter;
|
||||
|
@@ -5,7 +5,7 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* DateTime单元测试
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
@@ -32,6 +32,27 @@ public class DateTimeTest {
|
||||
Assert.assertEquals(5, day);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void datetimeTest2() {
|
||||
DateTime dateTime = new DateTime("2017-01-05 12:34:23");
|
||||
|
||||
// 年
|
||||
int year = dateTime.year();
|
||||
Assert.assertEquals(2017, year);
|
||||
|
||||
// 季度(非季节)
|
||||
Quarter season = dateTime.quarterEnum();
|
||||
Assert.assertEquals(Quarter.Q1, season);
|
||||
|
||||
// 月份
|
||||
Month month = dateTime.monthEnum();
|
||||
Assert.assertEquals(Month.JANUARY, month);
|
||||
|
||||
// 日
|
||||
int day = dateTime.dayOfMonth();
|
||||
Assert.assertEquals(5, day);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quarterTest() {
|
||||
DateTime dateTime = new DateTime("2017-01-05 12:34:23", DatePattern.NORM_DATETIME_FORMAT);
|
||||
@@ -90,7 +111,7 @@ public class DateTimeTest {
|
||||
int month = DateUtil.parse("2017-07-01").month();
|
||||
Assert.assertEquals(6, month);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void weekOfYearTest() {
|
||||
DateTime date = DateUtil.parse("2016-12-27");
|
||||
|
Reference in New Issue
Block a user