Example usage for org.joda.time Months THREE

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

Introduction

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

Prototype

Months THREE

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

Click Source Link

Document

Constant representing three months.

Usage

From source file:fr.aliacom.obm.common.calendar.CalendarBindingImpl.java

License:Open Source License

private SyncRange defaultSyncRange(Date date) {
    return new SyncRange(new org.joda.time.DateTime(date).plus(Months.SIX).toDate(),
            new org.joda.time.DateTime(date).minus(Months.THREE).toDate());
}

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

License:Open Source License

/**
 * Static factory method./*from   ww  w  . ja  va  2  s.c o  m*/
 *
 * 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
    }
}

From source file:org.zkoss.ganttz.timetracker.zoom.DetailTwoTimeTrackerState.java

License:Open Source License

@Override
protected ReadablePeriod getPeriodSecondLevel() {
    return Months.THREE;
}