Package org.joda.time

Examples of org.joda.time.DateMidnight


* @version $Revision$
*/
public class EventDateTimeUtilsTest {
    @Test
    public void testFindAcademicTerms() {
        final AcademicTermDetailImpl spring2012 = new AcademicTermDetailImpl(new DateMidnight(2012, 1, 1), new DateMidnight(2012, 6, 1), "Spring 2012");
        final AcademicTermDetailImpl summer2012 = new AcademicTermDetailImpl(new DateMidnight(2012, 6, 1), new DateMidnight(2012, 9, 1), "Summer 2012");
        final AcademicTermDetailImpl fall2012 = new AcademicTermDetailImpl(new DateMidnight(2012, 9, 1), new DateMidnight(2013, 1, 1), "Fall 2012");
       
        List<AcademicTermDetailImpl> terms = Arrays.asList(
                spring2012,
                summer2012,
                fall2012
        );
       
       
        AcademicTermDetailImpl result;
        Collections.sort(terms);
       
        result = EventDateTimeUtils.findDateRangeSorted(new DateMidnight(2011, 3, 1), terms);
        assertNull(result);
       
        result = EventDateTimeUtils.findDateRangeSorted(new DateMidnight(2012, 3, 1), terms);
        assertEquals(spring2012, result);
       
        result = EventDateTimeUtils.findDateRangeSorted(new DateMidnight(2012, 7, 1), terms);
        assertEquals(summer2012, result);
       
        result = EventDateTimeUtils.findDateRangeSorted(new DateMidnight(2012, 12, 31), terms);
        assertEquals(fall2012, result);
    }
View Full Code Here


  @Before
  public void setUp() {
      when(eventAggregationManagementDao.getQuartersDetails()).thenReturn(EventDateTimeUtils.createStandardQuarters());
     
      final List<AcademicTermDetail> terms = ImmutableList.<AcademicTermDetail>of(
              new AcademicTermDetailImpl(new DateMidnight(2012, 1, 12), new DateMidnight(2012, 4, 1), "spring 2"),
              new AcademicTermDetailImpl(new DateMidnight(2012, 4, 1), new DateMidnight(2012, 7, 1), "summer 2"),
                new AcademicTermDetailImpl(new DateMidnight(2012, 7, 1), new DateMidnight(2012, 12, 15), "fall 2"),
                new AcademicTermDetailImpl(new DateMidnight(2012, 12, 15), new DateMidnight(2013, 1, 14), "winter 2"),
                new AcademicTermDetailImpl(new DateMidnight(2015, 12, 15), new DateMidnight(2016, 1, 14), "winter 5")
        );
        when(eventAggregationManagementDao.getAcademicTermDetails()).thenReturn(terms);
  }
View Full Code Here

                }
            }
        }
       
        //Set the report end date as today
        final DateMidnight reportEnd;
        if (report.getEnd() == null) {
            reportEnd = new DateMidnight();
            report.setEnd(reportEnd);
        }
        else {
            reportEnd = report.getEnd();
        }
       
        //Determine the best start date based on the selected interval
        if (report.getStart() == null) {
            final DateMidnight start;
            switch (report.getInterval()) {
                case MINUTE: {
                    start = reportEnd.minusDays(1);
                    break;
                }
View Full Code Here

     * Build the aggregation {@link DataTable}
     */
    protected final DataTable buildAggregationReport(F form) throws TypeMismatchException {
        //Pull data out of form for per-group fetching
        final AggregationInterval interval = form.getInterval();
        final DateMidnight start = form.getStart();
        final DateMidnight end = form.getEnd();
       
        final DateTime startDateTime = start.toDateTime();
        //Use a query end of the end date at 23:59:59
        final DateTime endDateTime = end.plusDays(1).toDateTime().minusSeconds(1);

        //Get the list of DateTimes used on the X axis in the report
        final List<DateTime> reportTimes = this.intervalHelper.getIntervalStartDateTimesBetween(interval, startDateTime, endDateTime, maxIntervals);

        final Map<D, SortedSet<T>> groupedAggregations = createColumnDiscriminatorMap(form);
View Full Code Here

    /**
     * Format the Date as String, using the specified DateFormat.
     */
    @Override
    public String getAsText() {
        DateMidnight value = (DateMidnight) getValue();
        return (value != null ? this.dateFormat.print(value) : "");
    }
View Full Code Here

            final List<AcademicTermDetail> terms = getAcademicTermsAfter(start);
           
            //Count all the terms that are in the range, breaking the loop on the first non-matching term
            int count = 0;
            for (final AcademicTermDetail academicTerm : terms) {
                final DateMidnight termStart = academicTerm.getStart();
                if (end.isAfter(termStart) && !start.isAfter(termStart)) {
                    count++;
                }
                else if (count > 0) {
                    //getAcademicTermDetails returns the list in order, after at least one match has been found
View Full Code Here

            final List<AcademicTermDetail> terms = getAcademicTermsAfter(start);
           
            //Use all the terms that are in the range, breaking the loop on the first non-matching term
            final List<DateTime> result = new ArrayList<DateTime>(terms.size());
            for (final AcademicTermDetail academicTerm : terms) {
                final DateMidnight termStart = academicTerm.getStart();
                if (end.isAfter(termStart) && !start.isAfter(termStart)) {
                    result.add(start);
                }
                else if (!result.isEmpty()) {
                    //getAcademicTermDetails returns the list in order, after at least one match has been found
View Full Code Here

        }
       
        final LocalTime startTime = start.toLocalTime();
        final TimeDimension startTimeDimension = this.timeDimensionDao.getTimeDimensionByTime(startTime);

        final DateMidnight startDateMidnight = start.toDateMidnight();
        final DateDimension startDateDimension = this.dateDimensionDao.getDateDimensionByDate(startDateMidnight);
       
        return new AggregationIntervalInfo(interval, start, end, startDateDimension, startTimeDimension);
    }
View Full Code Here

        }
        else {
            endIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, newestPortalEventTimestamp.plus(this.dimensionBuffer));
        }
       
        final DateMidnight start = startIntervalInfo.getStart().toDateMidnight();
        final DateMidnight end = endIntervalInfo.getEnd().toDateMidnight();
       
        doPopulateDateDimensions(start, end);
    }
View Full Code Here

        final List<QuarterDetail> quartersDetails = this.eventAggregationManagementDao.getQuartersDetails();
        final List<AcademicTermDetail> academicTermDetails = this.eventAggregationManagementDao.getAcademicTermDetails();
       
        final List<DateDimension> dateDimensions = this.dateDimensionDao.getDateDimensionsBetween(start, end);
       
        DateMidnight nextDate = start;
        for (final DateDimension dateDimension : dateDimensions) {
            DateMidnight dimensionDate = dateDimension.getDate();
            if (nextDate.isBefore(dimensionDate)) {
                do {
                    checkShutdown();
                    createDateDimension(quartersDetails, academicTermDetails, nextDate);
                    nextDate = nextDate.plusDays(1);
                } while (nextDate.isBefore(dimensionDate));
            }
            else if (nextDate.isAfter(dimensionDate)) {
                do {
                    checkShutdown();
                    createDateDimension(quartersDetails, academicTermDetails, dimensionDate);
                    dimensionDate = dimensionDate.plusDays(1);
                } while (nextDate.isAfter(dimensionDate));
            }
           
            nextDate = dimensionDate.plusDays(1);
        }
       
        //Add any missing dates from the tail
        while (nextDate.isBefore(end)) {
            checkShutdown();
View Full Code Here

TOP

Related Classes of org.joda.time.DateMidnight

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.