use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.
the class PersianCalendarTest method testToIso.
@Test
void testToIso() {
assertEquals(new DateTimeUnit(1993, 3, 21, true), calendar.toIso(new DateTimeUnit(1372, 1, 1)));
assertEquals(new DateTimeUnit(2020, 3, 20, true), calendar.toIso(new DateTimeUnit(1399, 1, 1)));
assertEquals(new DateTimeUnit(2020, 3, 20, true), calendar.toIso(new DateTimeUnit(2020, 3, 20)));
}
use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.
the class PersianCalendarTest method testMinusMonths.
@Test
void testMinusMonths() {
DateTimeUnit dateTimeUnit = new DateTimeUnit(1382, 1, 20);
DateTimeUnit testDateTimeUnit = calendar.minusMonths(dateTimeUnit, 1);
assertEquals(1381, testDateTimeUnit.getYear());
assertEquals(12, testDateTimeUnit.getMonth());
assertEquals(20, testDateTimeUnit.getDay());
}
use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.
the class PersianCalendarTest method testPlusWeeks.
@Test
void testPlusWeeks() {
DateTimeUnit dateTimeUnit = new DateTimeUnit(1382, 1, 20);
DateTimeUnit testDateTimeUnit = calendar.plusWeeks(dateTimeUnit, 4);
assertEquals(1382, testDateTimeUnit.getYear());
assertEquals(2, testDateTimeUnit.getMonth());
assertEquals(17, testDateTimeUnit.getDay());
}
use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.
the class DateUtils method dateIsValid.
/**
* This method checks whether the String inDate is a valid date following
* the format "yyyy-MM-dd".
*
* @param calendar Calendar to be used
* @param dateString the string to be checked.
* @return true/false depending on whether the string is a date according to the format "yyyy-MM-dd".
*/
public static boolean dateIsValid(org.hisp.dhis.calendar.Calendar calendar, String dateString) {
Matcher matcher = DEFAULT_DATE_REGEX_PATTERN.matcher(dateString);
if (!matcher.matches()) {
return false;
}
DateTimeUnit dateTime = new DateTimeUnit(Integer.valueOf(matcher.group("year")), Integer.valueOf(matcher.group("month")), Integer.valueOf(matcher.group("day")));
return calendar.isValid(dateTime);
}
use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.
the class BiMonthlyPeriodType method getNextPeriod.
// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
@Override
public Period getNextPeriod(Period period, Calendar calendar) {
DateTimeUnit dateTimeUnit = calendar.fromIso(DateTimeUnit.fromJdkDate(period.getStartDate()));
dateTimeUnit = calendar.plusMonths(dateTimeUnit, 2);
return createPeriod(dateTimeUnit, calendar);
}
Aggregations