Search in sources :

Example 1 with Month

use of cn.hutool.core.date.Month in project hutool by looly.

the class DateTimeTest method datetimeTest.

@Test
public void datetimeTest() {
    DateTime dateTime = new DateTime("2017-01-05 12:34:23", DatePattern.NORM_DATETIME_FORMAT);
    // 年
    int year = dateTime.year();
    Assert.assertEquals(2017, year);
    // 季度(非季节)
    Season season = dateTime.seasonEnum();
    Assert.assertEquals(Season.SPRING, season);
    // 月份
    Month month = dateTime.monthEnum();
    Assert.assertEquals(Month.JANUARY, month);
    // 日
    int day = dateTime.dayOfMonth();
    Assert.assertEquals(5, day);
}
Also used : Month(cn.hutool.core.date.Month) Season(cn.hutool.core.date.Season) DateTime(cn.hutool.core.date.DateTime) Test(org.junit.Test)

Aggregations

DateTime (cn.hutool.core.date.DateTime)1 Month (cn.hutool.core.date.Month)1 Season (cn.hutool.core.date.Season)1 Test (org.junit.Test)1