Search in sources :

Example 41 with DateTimeUnit

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

the class DailyPeriodType method getPreviousPeriod.

@Override
public Period getPreviousPeriod(Period period, Calendar calendar) {
    DateTimeUnit dateTimeUnit = createLocalDateUnitInstance(period.getStartDate(), calendar);
    dateTimeUnit = calendar.minusDays(dateTimeUnit, 1);
    Date date = calendar.toIso(dateTimeUnit).toJdkDate();
    return new Period(this, date, date);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) Date(java.util.Date)

Example 42 with DateTimeUnit

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

the class DailyPeriodType method getNextPeriod.

// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
@Override
public Period getNextPeriod(Period period, Calendar calendar) {
    DateTimeUnit dateTimeUnit = createLocalDateUnitInstance(period.getStartDate(), calendar);
    dateTimeUnit = calendar.plusDays(dateTimeUnit, 1);
    Date date = calendar.toIso(dateTimeUnit).toJdkDate();
    return new Period(this, date, date);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) Date(java.util.Date)

Example 43 with DateTimeUnit

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

the class FinancialPeriodType method getPreviousPeriod.

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

Example 44 with DateTimeUnit

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

the class FinancialPeriodType 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 45 with DateTimeUnit

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

the class MonthlyPeriodType method getPreviousPeriod.

@Override
public Period getPreviousPeriod(Period period, Calendar calendar) {
    DateTimeUnit dateTimeUnit = calendar.fromIso(DateTimeUnit.fromJdkDate(period.getStartDate()));
    dateTimeUnit = calendar.minusMonths(dateTimeUnit, 1);
    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