Search in sources :

Example 46 with DateTimeUnit

use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.

the class SixMonthlyAbstractPeriodType method getNextPeriod.

// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
@Override
public Period getNextPeriod(Period period, Calendar calendar) {
    DateTimeUnit dateTimeUnit = calendar.fromIso(DateTimeUnit.fromJdkDate(period.getStartDate()));
    dateTimeUnit = calendar.plusMonths(dateTimeUnit, 6);
    return createPeriod(calendar.toIso(dateTimeUnit), calendar);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit)

Example 47 with DateTimeUnit

use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.

the class SixMonthlyAbstractPeriodType method getPreviousPeriod.

@Override
public Period getPreviousPeriod(Period period, Calendar calendar) {
    DateTimeUnit dateTimeUnit = calendar.fromIso(DateTimeUnit.fromJdkDate(period.getStartDate()));
    dateTimeUnit = calendar.minusMonths(dateTimeUnit, 6);
    return createPeriod(dateTimeUnit, calendar);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit)

Example 48 with DateTimeUnit

use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.

the class YearlyPeriodType method getNextPeriod.

// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
@Override
public Period getNextPeriod(Period period, Calendar calendar) {
    DateTimeUnit dateTimeUnit = createLocalDateUnitInstance(period.getStartDate(), calendar);
    dateTimeUnit = calendar.plusYears(dateTimeUnit, 1);
    return createPeriod(dateTimeUnit, calendar);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit)

Example 49 with DateTimeUnit

use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.

the class WeeklyAbstractPeriodType method getNextPeriod.

@Override
public Period getNextPeriod(Period period, Calendar calendar) {
    DateTimeUnit dateTimeUnit = createLocalDateUnitInstance(period.getStartDate(), calendar);
    dateTimeUnit = calendar.plusWeeks(dateTimeUnit, 1);
    return createPeriod(dateTimeUnit, calendar);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit)

Example 50 with DateTimeUnit

use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.

the class QuarterlyPeriodType method getNextPeriod.

// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
@Override
public Period getNextPeriod(Period period, org.hisp.dhis.calendar.Calendar calendar) {
    DateTimeUnit dateTimeUnit = createLocalDateUnitInstance(period.getStartDate(), calendar);
    dateTimeUnit = calendar.plusMonths(dateTimeUnit, 3);
    return createPeriod(dateTimeUnit, calendar);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit)

Aggregations

DateTimeUnit (org.hisp.dhis.calendar.DateTimeUnit)98 Calendar (org.hisp.dhis.calendar.Calendar)23 Test (org.junit.jupiter.api.Test)17 Date (java.util.Date)15 DateInterval (org.hisp.dhis.calendar.DateInterval)10 Period (org.hisp.dhis.period.Period)6 DateTime (org.joda.time.DateTime)5 LocalDate (java.time.LocalDate)4 DimensionalObject (org.hisp.dhis.common.DimensionalObject)4 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)4 ArrayList (java.util.ArrayList)3 WeekFields (java.time.temporal.WeekFields)2 HashMap (java.util.HashMap)2 Matcher (java.util.regex.Matcher)2 InvalidCalendarParametersException (org.hisp.dhis.calendar.exception.InvalidCalendarParametersException)2 DataDimensionalItemObject (org.hisp.dhis.common.DataDimensionalItemObject)2 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)2 DataElement (org.hisp.dhis.dataelement.DataElement)2 DateUtils.getMediumDateString (org.hisp.dhis.system.util.DateUtils.getMediumDateString)2 DateUtils.getMediumDateString (org.hisp.dhis.util.DateUtils.getMediumDateString)2