Example usage for org.joda.time DateTime toDateMidnight

List of usage examples for org.joda.time DateTime toDateMidnight

Introduction

In this page you can find the example usage for org.joda.time DateTime toDateMidnight.

Prototype

@Deprecated
public DateMidnight toDateMidnight() 

Source Link

Document

Converts this object to a DateMidnight using the same millis and chronology.

Usage

From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsHelper.java

License:Open Source License

public List<DateTime> getDaysBetweenGivenDates(final Entity entity) {
    List<DateTime> days = new LinkedList<DateTime>();

    DateTime dateFrom = new DateTime((Date) entity.getField(DATE_FROM));
    DateTime dateTo = new DateTime((Date) entity.getField(DATE_TO));

    DateTime nextDay = dateFrom;//from   w  w w. j  a va2 s  . c o m

    int numberOfDays = Days.daysBetween(dateFrom.toDateMidnight(), dateTo.toDateMidnight()).getDays();

    days.add(nextDay);

    int oneDay = 1;
    while (numberOfDays != 0) {
        nextDay = nextDay.plusDays(oneDay).toDateTime();
        days.add(nextDay);
        numberOfDays--;
    }

    return days;
}

From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsHelper.java

License:Open Source License

public int getNumberOfDaysBetweenGivenDates(final Entity entity) {
    DateTime dateFrom = new DateTime((Date) entity.getField(DATE_FROM));
    DateTime dateTo = new DateTime((Date) entity.getField(DATE_TO));

    return Days.daysBetween(dateFrom.toDateMidnight(), dateTo.toDateMidnight()).getDays();
}

From source file:com.qcadoo.mes.avgLaborCostCalcForOrder.AverageCostService.java

License:Open Source License

private List<DateTime> getDaysBetweenGivenDates(final Date start, final Date finish) {
    List<DateTime> days = new LinkedList<DateTime>();
    DateTime startDate = new DateTime(start);
    DateTime finishDate = new DateTime(finish);

    DateTime nextDay = startDate;/* w  ww. j  a  va2  s  . c  o  m*/
    int numberOfDays = Days.daysBetween(startDate.toDateMidnight(), finishDate.toDateMidnight()).getDays();
    days.add(nextDay);

    int oneDay = 1;
    while (numberOfDays != 0) {
        nextDay = nextDay.plusDays(oneDay).toDateTime();
        days.add(nextDay);
        numberOfDays--;
    }
    return days;
}

From source file:com.thingsee.tracker.libs.SmartDateTimeUtil.java

License:Apache License

private static boolean isToday(DateTime dateTime) {
    DateMidnight today = new DateMidnight();
    return today.equals(dateTime.toDateMidnight());
}

From source file:com.thingsee.tracker.libs.SmartDateTimeUtil.java

License:Apache License

private static boolean isYesterday(DateTime dateTime) {
    DateMidnight yesterday = (new DateMidnight()).minusDays(1);
    return yesterday.equals(dateTime.toDateMidnight());
}

From source file:com.thingsee.tracker.libs.SmartDateTimeUtil.java

License:Apache License

private static boolean isTomorrow(DateTime dateTime) {
    DateMidnight tomorrow = (new DateMidnight()).plusDays(1);
    return tomorrow.equals(dateTime.toDateMidnight());
}

From source file:dk.teachus.backend.domain.impl.BookingsImpl.java

License:Apache License

public Booking getBooking(Period period, DateTime time) {
    Booking booking = null;/*from  w  ww .  ja va  2 s .com*/

    for (Booking foundBooking : bookings) {
        if (foundBooking.getPeriod().getId().equals(period.getId())) {
            DateTime dt1 = foundBooking.getDate();
            DateTime dt2 = time;

            if (dt1.toDateMidnight().equals(dt2.toDateMidnight())) {
                if (dt1.getHourOfDay() == dt2.getHourOfDay()
                        && dt1.getMinuteOfHour() == dt2.getMinuteOfHour()) {
                    booking = foundBooking;
                    break;
                }
            }
        }
    }

    return booking;
}

From source file:dk.teachus.backend.domain.impl.PeriodImpl.java

License:Apache License

public boolean conflicts(DateTime bookedTime, DateTime time) {
    boolean conflicts = false;

    // On the same date
    if (bookedTime.toDateMidnight().equals(time.toDateMidnight())) {
        bookedTime = DateUtils.resetDateTime(bookedTime, time);
        time = DateUtils.resetDateTime(time, time);

        DateTime st = bookedTime.minusMinutes(lessonDuration);
        DateTime et = bookedTime.plusMinutes(lessonDuration);

        Interval bookedInterval = new Interval(st, et);

        if (bookedInterval.contains(time) && st.equals(time) == false) {
            conflicts = true;/*from  w w  w  .  ja va 2s  .  c  o m*/
        }
    }

    return conflicts;
}

From source file:dk.teachus.backend.domain.impl.PeriodImpl.java

License:Apache License

public boolean hasDate(DateTime dateTime) {
    return hasDate(dateTime.toDateMidnight());
}

From source file:dk.teachus.backend.domain.impl.PeriodImpl.java

License:Apache License

public boolean inLesson(DateTime bookedTime, DateTime time) {
    boolean inLesson = false;

    // On the same date
    if (bookedTime.toDateMidnight().equals(time.toDateMidnight())) {
        bookedTime = DateUtils.resetDateTime(bookedTime, time);
        time = DateUtils.resetDateTime(time, time);

        DateTime et = bookedTime.plusMinutes(lessonDuration);

        Interval bookedInterval = new Interval(bookedTime, et);

        if (bookedInterval.contains(time) && bookedTime.equals(time) == false) {
            inLesson = true;/*from ww  w.ja v  a 2 s .  com*/
        }
    }

    return inLesson;
}