Add gets the current day of year. (#968)

This commit is contained in:
Arturo Bernal 2022-10-13 19:14:22 +02:00 committed by GitHub
parent ff733d9d9b
commit 59d201f7be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -77,6 +77,16 @@ public class CalendarUtils {
return calendar.get(Calendar.DAY_OF_MONTH);
}
/**
* Gets the current day of year.
*
* @return the current day of year.
* @since 3.13.0
*/
public int getDayOfYear() {
return calendar.get(Calendar.DAY_OF_YEAR);
}
/**
* Gets the current month.
*

View File

@ -32,6 +32,11 @@ public class CalendarUtilsTest extends AbstractLangTest {
assertEquals(Calendar.getInstance().get(Calendar.DAY_OF_MONTH), CalendarUtils.INSTANCE.getDayOfMonth());
}
@Test
public void testGetDayOfYear() {
assertEquals(Calendar.getInstance().get(Calendar.DAY_OF_YEAR), CalendarUtils.INSTANCE.getDayOfYear());
}
@Test
public void testGetMonth() {
assertEquals(Calendar.getInstance().get(Calendar.MONTH), CalendarUtils.INSTANCE.getMonth());