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;
}
}
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;
}
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);
}
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());
}
}
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);
}
Aggregations