Search in sources :

Example 31 with DateMidnight

use of org.joda.time.DateMidnight in project OpenClinica by OpenClinica.

the class ArithmeticOpNode method calculateGenericDate.

private String calculateGenericDate(String value1, String value2) {
    DateMidnight dm = new DateMidnight(ExpressionTreeHelper.getDate(value1).getTime());
    DateTimeFormatter fmt = ISODateTimeFormat.date();
    switch(op) {
        case PLUS:
            {
                dm = dm.plusDays(Double.valueOf(value2).intValue());
                return fmt.print(dm);
            }
        case MINUS:
            {
                dm = dm.minusDays(Double.valueOf(value2).intValue());
                return fmt.print(dm);
            }
        default:
            // Bad operator!
            return null;
    }
}
Also used : DateMidnight(org.joda.time.DateMidnight) DateTimeFormatter(org.joda.time.format.DateTimeFormatter)

Example 32 with DateMidnight

use of org.joda.time.DateMidnight in project OpenClinica by OpenClinica.

the class ExpressionService method getSSDate.

public HashMap<String, String> getSSDate(String ssZoneId, String serverZoneId) {
    HashMap<String, String> map = new HashMap<String, String>();
    if (ssZoneId == null || ssZoneId.equals(""))
        ssZoneId = TimeZone.getDefault().getID();
    DateTimeZone ssZone = DateTimeZone.forID(ssZoneId);
    DateMidnight dm = new DateMidnight(ssZone);
    DateTimeFormatter fmt = ISODateTimeFormat.date();
    map.put("ssDate", fmt.print(dm));
    map.put("serverZoneId", serverZoneId);
    DateTimeZone serverZone = DateTimeZone.forID(serverZoneId);
    DateMidnight serverDate = new DateMidnight(serverZone);
    map.put("serverDate", fmt.print(serverDate));
    return map;
}
Also used : HashMap(java.util.HashMap) DateMidnight(org.joda.time.DateMidnight) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTimeZone(org.joda.time.DateTimeZone)

Example 33 with DateMidnight

use of org.joda.time.DateMidnight in project uPortal by Jasig.

the class PortalEventDimensionPopulatorImplTest method populateDefaultDateDimensions.

@Test
public void populateDefaultDateDimensions() {
    final DateTime now = new DateTime(1325881376117l);
    final Period dimensionBuffer = Period.days(30);
    final DateTime oldestPortalEvent = now.minusDays(30);
    final DateTime newestPortalEvent = now;
    final DateTime dimensionStart = oldestPortalEvent.minus(dimensionBuffer);
    final DateTime dimensionEnd = newestPortalEvent.plus(dimensionBuffer);
    when(dateDimensionDao.getDateDimensionsBetween(any(DateMidnight.class), any(DateMidnight.class))).thenReturn(Collections.<DateDimension>emptyList());
    when(portalEventDao.getOldestPortalEventTimestamp()).thenReturn(oldestPortalEvent);
    when(portalEventDao.getOldestPortalEventTimestamp()).thenReturn(oldestPortalEvent);
    final AggregationIntervalInfo startIntervalInfo = mock(AggregationIntervalInfo.class);
    when(startIntervalInfo.getStart()).thenReturn(dimensionStart.year().roundFloorCopy());
    final AggregationIntervalInfo endIntervalInfo = mock(AggregationIntervalInfo.class);
    when(endIntervalInfo.getEnd()).thenReturn(dimensionStart.year().roundCeilingCopy());
    when(aggregationIntervalHelper.getIntervalInfo(AggregationInterval.YEAR, dimensionStart)).thenReturn(startIntervalInfo);
    when(aggregationIntervalHelper.getIntervalInfo(AggregationInterval.YEAR, dimensionEnd)).thenReturn(endIntervalInfo);
    when(eventAggregationManagementDao.getAcademicTermDetails()).thenReturn(Collections.<AcademicTermDetail>emptyList());
    when(eventAggregationManagementDao.getQuartersDetails()).thenReturn(EventDateTimeUtils.createStandardQuarters());
    portalEventDimensionPopulator.setDimensionBuffer(dimensionBuffer);
    portalEventDimensionPopulator.doPopulateDateDimensions();
    verify(dateDimensionDao).getDateDimensionsBetween(any(DateMidnight.class), any(DateMidnight.class));
    verify(dateDimensionDao, times(365)).createDateDimension(Matchers.<DateMidnight>anyObject(), anyInt(), anyString());
    verifyNoMoreInteractions(timeDimensionDao, dateDimensionDao);
}
Also used : DateMidnight(org.joda.time.DateMidnight) Period(org.joda.time.Period) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 34 with DateMidnight

use of org.joda.time.DateMidnight in project joda-time by JodaOrg.

the class TestISOChronology method testMaximumValue.

public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1);
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
Also used : DateMidnight(org.joda.time.DateMidnight) YearMonthDay(org.joda.time.YearMonthDay)

Example 35 with DateMidnight

use of org.joda.time.DateMidnight in project uPortal by Jasig.

the class QuarterDetailImpl method compareTo.

@Override
public int compareTo(ReadableInstant instant) {
    final DateMidnight startDateTime = this.getStartDateMidnight(instant);
    final DateMidnight endDateTime = this.getEndDateMidnight(instant);
    return EventDateTimeUtils.compareTo(startDateTime, endDateTime, instant);
}
Also used : DateMidnight(org.joda.time.DateMidnight)

Aggregations

DateMidnight (org.joda.time.DateMidnight)70 DateTime (org.joda.time.DateTime)33 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)10 Money (org.mifos.framework.util.helpers.Money)10 Ignore (org.junit.Ignore)8 MeetingBO (org.mifos.application.meeting.business.MeetingBO)8 LocalDate (org.joda.time.LocalDate)6 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)6 Holiday (org.mifos.application.holiday.business.Holiday)6 Date (java.util.Date)5 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)5 OfficeBO (org.mifos.customers.office.business.OfficeBO)5 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)5 AggregationInterval (org.apereo.portal.events.aggr.AggregationInterval)4 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)4 UserContext (org.mifos.security.util.UserContext)4 DateTimeZone (org.joda.time.DateTimeZone)3 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 Before (org.junit.Before)3