Example usage for org.joda.time Days THREE

List of usage examples for org.joda.time Days THREE

Introduction

In this page you can find the example usage for org.joda.time Days THREE.

Prototype

Days THREE

To view the source code for org.joda.time Days THREE.

Click Source Link

Document

Constant representing three days.

Usage

From source file:com.marand.thinkmed.medications.pharmacist.impl.PharmacistTaskHandlerImpl.java

License:Open Source License

private PrescriptionChangeTypeEnum getPharmacistTherapyChangeType(final String patientId,
        final DateTime hospitalizationStart, final DateTime when) {
    if (hospitalizationStart == null) {
        return PrescriptionChangeTypeEnum.NEW_ADMISSION_PRESCRIPTION;
    }//from   w  w w.  j  av a 2  s  .  c  o m

    return medicationsOpenEhrDao
            .findMedicationInstructions(patientId, new Interval(hospitalizationStart, Days.THREE), null)
            .stream().filter(Objects::nonNull).findFirst().map(Pair::getFirst)
            .map(c -> new Interval(DataValueUtils.getDateTime(c.getCompositionEventContext().getStartTime()),
                    Hours.ONE))
            .map(interval -> interval.contains(when) ? PrescriptionChangeTypeEnum.NEW_ADMISSION_PRESCRIPTION
                    : PrescriptionChangeTypeEnum.ADDITION_TO_EXISTING_PRESCRIPTION)
            .orElse(PrescriptionChangeTypeEnum.NEW_ADMISSION_PRESCRIPTION);
}

From source file:org.mifos.calendar.DayOfWeek.java

License:Open Source License

public static int wednesday() {
    return Days.THREE.getDays();
}

From source file:org.sleuthkit.autopsy.timeline.utils.RangeDivisionInfo.java

License:Open Source License

/**
 * Static factory method.//  w w w. j ava2s  .  c  om
 *
 * Determine the period size, number of periods, whole period bounds, and
 * formatters to use to visualize the given timerange.
 *
 * @param timeRange
 *
 * @return
 */
public static RangeDivisionInfo getRangeDivisionInfo(Interval timeRange) {
    //Check from largest to smallest unit

    //TODO: make this more generic... reduce code duplication -jm
    DateTimeFieldType timeUnit;
    final DateTime startWithZone = timeRange.getStart().withZone(TimeLineController.getJodaTimeZone());
    final DateTime endWithZone = timeRange.getEnd().withZone(TimeLineController.getJodaTimeZone());

    if (Years.yearsIn(timeRange).isGreaterThan(Years.THREE)) {
        timeUnit = DateTimeFieldType.year();
        long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
        long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
        return new RangeDivisionInfo(timeRange, Years.yearsIn(timeRange).get(timeUnit.getDurationType()) + 1,
                TimeUnits.YEARS, ISODateTimeFormat.year(), lower, upper);
    } else if (Months.monthsIn(timeRange).isGreaterThan(Months.THREE)) {
        timeUnit = DateTimeFieldType.monthOfYear();
        long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
        long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
        return new RangeDivisionInfo(timeRange, Months.monthsIn(timeRange).getMonths() + 1, TimeUnits.MONTHS,
                DateTimeFormat.forPattern("YYYY'-'MMMM"), lower, upper); // NON-NLS
    } else if (Days.daysIn(timeRange).isGreaterThan(Days.THREE)) {
        timeUnit = DateTimeFieldType.dayOfMonth();
        long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
        long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
        return new RangeDivisionInfo(timeRange, Days.daysIn(timeRange).getDays() + 1, TimeUnits.DAYS,
                DateTimeFormat.forPattern("YYYY'-'MMMM'-'dd"), lower, upper); // NON-NLS
    } else if (Hours.hoursIn(timeRange).isGreaterThan(Hours.THREE)) {
        timeUnit = DateTimeFieldType.hourOfDay();
        long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
        long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
        return new RangeDivisionInfo(timeRange, Hours.hoursIn(timeRange).getHours() + 1, TimeUnits.HOURS,
                DateTimeFormat.forPattern("YYYY'-'MMMM'-'dd HH"), lower, upper); // NON-NLS
    } else if (Minutes.minutesIn(timeRange).isGreaterThan(Minutes.THREE)) {
        timeUnit = DateTimeFieldType.minuteOfHour();
        long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
        long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
        return new RangeDivisionInfo(timeRange, Minutes.minutesIn(timeRange).getMinutes() + 1,
                TimeUnits.MINUTES, DateTimeFormat.forPattern("YYYY'-'MMMM'-'dd HH':'mm"), lower, upper); // NON-NLS
    } else {
        timeUnit = DateTimeFieldType.secondOfMinute();
        long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
        long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
        return new RangeDivisionInfo(timeRange, Seconds.secondsIn(timeRange).getSeconds() + 1,
                TimeUnits.SECONDS, DateTimeFormat.forPattern("YYYY'-'MMMM'-'dd HH':'mm':'ss"), lower, upper); // NON-NLS
    }
}