Example usage for org.joda.time DateTime plus

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

Introduction

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

Prototype

public DateTime plus(ReadablePeriod period) 

Source Link

Document

Returns a copy of this datetime with the specified period added.

Usage

From source file:ke.co.tawi.babblesms.server.servlet.report.chart.bar.IncomingBarDay.java

License:Open Source License

/**
 * Creates Json information for incoming SMS information against all
 * {@link Network}s./*ww  w .j a v a2s. com*/
 * <p>
 * An example is:<br/>
 * {"incomingData":[{"date":"Apr 20","orange_ke":98,"safaricom_ke":145,"airtel_ke":63},
           {"date":"Apr 21","orange_ke":70,"safaricom_ke":180,"airtel_ke":120},
          {"date":"Apr 22","orange_ke":20,"safaricom_ke":100,"airtel_ke":140},
           {"date":"Apr 23","orange_ke":5,"safaricom_ke":20,"airtel_ke":9},
          {"date":"Apr 24","orange_ke":65,"safaricom_ke":56,"airtel_ke":10},
          {"date":"Apr 25","orange_ke":27,"safaricom_ke":72,"airtel_ke":75},
          {"date":"Apr 26","orange_ke":102,"safaricom_ke":63,"airtel_ke":48} ]}
 *
 * @return a Json String
 */
private String getJsonIncoming(String accountUuid) {

    Gson g = new GsonBuilder().disableHtmlEscaping().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
            .setPrettyPrinting().serializeNulls().create();

    HashMap<String, List<Map<String, Object>>> countHash = new HashMap<>();

    SessionStatistics statistics = new SessionStatistics();
    Element element;
    String dateStr;
    if ((element = statisticsCache.get(accountUuid)) != null) {
        statistics = (SessionStatistics) element.getObjectValue();
    }
    Map<String, Map<Network, Integer>> networkIncomingUSSDCountDay = new HashMap<String, Map<Network, Integer>>();

    DateTime dateMidnightStart;
    // TODO sort out calculations of dates
    if (fromDate == null) {
        dateMidnightStart = new DateTime(fromDate);
    } else {
        dateMidnightStart = DateTime.now().minus(Hours.hours(24 * (DAY_COUNT)));

    }

    int numDays = 0;

    if ((element = statisticsCache.get(accountUuid)) != null) {
        statistics = (SessionStatistics) element.getObjectValue();
    }

    networkIncomingUSSDCountDay = statistics.getNetworkIncomingUSSDCountDay();

    Map<Network, Integer> networkIncomingUSSDCount;
    // Hold the network and dates with SMS counts
    ArrayList<Map<String, Object>> dateNetworkCountArray = new ArrayList<Map<String, Object>>();

    Iterator<Network> networkIter;
    Network network;

    do {
        dateStr = new SimpleDateFormat("MMM d").format(new Date(dateMidnightStart.getMillis()));
        networkIncomingUSSDCount = networkIncomingUSSDCountDay.get(dateStr);

        // recreate the Map in order to void duplicating data
        HashMap<String, Object> dateNetworkCount = new HashMap<String, Object>();

        // It is possible that on particular days the account has no
        // incoming SMS
        if (networkIncomingUSSDCount != null) {
            networkIter = networkIncomingUSSDCount.keySet().iterator();
            dateNetworkCount.put("date", dateStr.toString());
            while (networkIter.hasNext()) {

                network = networkIter.next();
                // add network names and SMS count to Map. Remove spaces in
                // the network name to avoid typeErrors in JavaScript
                dateNetworkCount.put(network.getName().replace(" ", "_").toLowerCase(),
                        networkIncomingUSSDCount.get(network));

            }
            // add the network statistics and the date to an array. It will
            // be converted to a JSON array
            dateNetworkCountArray.add(dateNetworkCount);

        }
        // increase the date by 24hours
        dateMidnightStart = dateMidnightStart.plus(Hours.hours(24));
        numDays++;

    } while (numDays < DAY_COUNT);
    // finally put the array into a Map which can be converted into a JSON
    // object
    countHash.put("incomingData", dateNetworkCountArray);
    return g.toJson(countHash);
}

From source file:ke.co.tawi.babblesms.server.servlet.report.chart.bar.OutgoingBarDay.java

License:Open Source License

/**
 * Creates Json information for outgoing SMS information against all
 * {@link Network}s./*  ww w .java 2 s . c om*/
 * <p>
 * An example is:<br/>
 * {"outgoingData":[{"date":"Apr 20","orange_ke":98,"safaricom_ke":145,"airtel_ke":63},
 *               {"date":"Apr 21","orange_ke":70,"safaricom_ke":180,"airtel_ke":120},
          {"date":"Apr 22","orange_ke":20,"safaricom_ke":100,"airtel_ke":140},
           {"date":"Apr 23","orange_ke":5,"safaricom_ke":20,"airtel_ke":9},
          {"date":"Apr 24","orange_ke":65,"safaricom_ke":56,"airtel_ke":10},
          {"date":"Apr 25","orange_ke":27,"safaricom_ke":72,"airtel_ke":75},
          {"date":"Apr 26","orange_ke":102,"safaricom_ke":63,"airtel_ke":48} ]}
 * 
 * @return a Json String
 */
private String getJsonOutgoing(String accountUuid) {
    Gson g = new GsonBuilder().disableHtmlEscaping().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
            .setPrettyPrinting().serializeNulls().create();

    HashMap<String, ArrayList<Map<String, Object>>> countHash = new HashMap<>();

    SessionStatistics statistics = new SessionStatistics();
    Element element;
    String dateStr;
    if ((element = statisticsCache.get(accountUuid)) != null) {
        statistics = (SessionStatistics) element.getObjectValue();
    }
    Map<String, Map<Network, Integer>> networkOutgoingUSSDCountDay = new HashMap<String, Map<Network, Integer>>();
    // TODO sort out calculations of dates
    DateTime dateMidnightStart;
    if (fromDate == null) {
        dateMidnightStart = new DateTime(fromDate);
    } else {
        dateMidnightStart = DateTime.now().minus(Hours.hours(24 * (DAY_COUNT)));
    }

    int numDays = 0;

    if ((element = statisticsCache.get(accountUuid)) != null) {
        statistics = (SessionStatistics) element.getObjectValue();
    }

    networkOutgoingUSSDCountDay = statistics.getNetworkOutgoingUSSDCountDay();

    Map<Network, Integer> networkOutgoingUSSDCount;
    // Hold the network and dates with SMS counts
    ArrayList<Map<String, Object>> dateNetworkCountArray = new ArrayList<Map<String, Object>>();

    Iterator<Network> networkIter;
    Network network;

    do {
        dateStr = new SimpleDateFormat("MMM d").format(new Date(dateMidnightStart.getMillis()));
        networkOutgoingUSSDCount = networkOutgoingUSSDCountDay.get(dateStr);

        // recreate the Map in order to void duplicating data
        HashMap<String, Object> dateNetworkCount = new HashMap<String, Object>();

        // It is possible that on particular days the account has no
        // incoming SMS
        if (networkOutgoingUSSDCount != null) {
            networkIter = networkOutgoingUSSDCount.keySet().iterator();
            dateNetworkCount.put("date", dateStr.toString());
            while (networkIter.hasNext()) {

                network = networkIter.next();
                // add network names and SMS count to Map. Remove spaces in
                // the network name to avoid typeErrors in JavaScript
                dateNetworkCount.put(network.getName().replace(" ", "_").toLowerCase(),
                        networkOutgoingUSSDCount.get(network));

            }
            // add the network statistics and the date to an array. It will
            // be converted to a JSON array
            dateNetworkCountArray.add(dateNetworkCount);
        }

        dateMidnightStart = dateMidnightStart.plus(Hours.hours(24));
        numDays++;

    } while (numDays < DAY_COUNT);
    // finally put the array into a Map which can be converted into a JSON
    // object
    countHash.put("outgoingData", dateNetworkCountArray);
    return g.toJson(countHash);
}

From source file:ke.co.tawi.babblesms.server.session.SessionStatisticsFactory.java

License:Open Source License

/**
 *
 * @param accountUuid/*w  w  w . jav  a 2 s .  c  om*/
 * @return session statistics
 */
public static SessionStatistics getSessionStatistics(String accountUuid) {
    int count;
    //int[] arraycount = new int[2];

    SessionStatistics stats = new SessionStatistics();

    // Get the list of all networks
    List<Network> networkList = networkDAO.getAllNetworks();
    ;

    //set the count of all incoming SMS
    stats.setAllIncomingSMSCount(countUtils.getIncomingCount(accountUuid));

    //set the count of all outgoing SMS
    stats.setAllOutgoingSMSCount(countUtils.getOutgoingLog(accountUuid));

    //set the count of all outgoing Group SMS
    //stats.setAllOutgoingSMSCount(countUtils.getOutgoingGroupLog(accountUuid));

    // Set up data for the pie charts
    for (Network network : networkList) {
        //get the count of incoming SMS according to the account and network
        count = countUtils.getIncomingCount(accountUuid, network);

        //if count is greater than zero, add the information
        if (count > 0) {
            stats.addNetworkIncomingCount(network, count);
        }

        //get the count of outgoing SMS according to the account and network
        count = countUtils.getOutgoingCount(accountUuid, network);

        //if count is greater than zero, add the information
        if (count > 0) {
            stats.addNetworkOutgoingSMSCount(network, count);
        }
    }

    // Set up data for the bar charts
    DateTime dateMidnightStart = DateTime.now().minus(Hours.hours(24 * (IncomingBarDay.DAY_COUNT)));
    DateTime dateMidnightEnd = dateMidnightStart.plus(Hours.hours(24));
    int numDays = 0;
    do {
        for (Network network : networkList) {

            //get the daily count for incoming
            count = countUtils.getIncomingCount(accountUuid, network, new Date(dateMidnightStart.getMillis()),
                    new Date(dateMidnightEnd.getMillis()));
            if (count > 0) {
                stats.addNetworkIncomingUSSDCountDay(
                        new SimpleDateFormat("MMM d").format(new Date(dateMidnightStart.getMillis())), network,
                        count);
            }
            //get the daily count for outgoing
            count = countUtils.getOutgoingCount(accountUuid, network, new Date(dateMidnightStart.getMillis()),
                    new Date(dateMidnightEnd.getMillis()));

            if (count > 0) {
                stats.addNetworkOutgoingUSSDCountDay(
                        new SimpleDateFormat("MMM d").format(new Date(dateMidnightStart.getMillis())), network,
                        count);
            }

        }
        dateMidnightStart = dateMidnightStart.plus(Hours.hours(24));
        dateMidnightEnd = dateMidnightEnd.plus(Hours.hours(24));
        numDays++;
    } while (numDays < IncomingBarDay.DAY_COUNT);

    // Set up data for the Weekly bar charts                
    int numWeeks = 0;
    MutableDateTime startwkMutableDateTime = new MutableDateTime();
    MutableDateTime endwkMutableDateTime;
    startwkMutableDateTime.setDayOfWeek(1); //get the first day of the week
    startwkMutableDateTime.setMillisOfDay(0); //get 00:00:00 time of the day

    //go back to 7 weeks
    startwkMutableDateTime.addWeeks(-7);

    do {
        // set the end date by creating a copy
        endwkMutableDateTime = new MutableDateTime(startwkMutableDateTime);
        //push it by one week
        endwkMutableDateTime.addWeeks(1);

        for (Network network : networkList) {

            //get the Weekly count for Incoming USSD
            count = countUtils.getIncomingCount(accountUuid, network,
                    new Date(startwkMutableDateTime.toDate().getTime()),
                    new Date(endwkMutableDateTime.toDate().getTime()));

            if (count > 0) {
                stats.addNetworkIncomingUSSDCountWeek(
                        new SimpleDateFormat("MMM d").format(new Date(startwkMutableDateTime.getMillis())),
                        network, count);
            }

            //get the Weekly count for Outgoing USSD
            count = countUtils.getOutgoingCount(accountUuid, network,
                    new Date(startwkMutableDateTime.toDate().getTime()),
                    new Date(endwkMutableDateTime.toDate().getTime()));
            if (count > 0) {
                stats.addNetworkOutgoingUSSDCountWeek(
                        new SimpleDateFormat("MMM d").format(new Date(startwkMutableDateTime.getMillis())),
                        network, count);
            }

        }
        // get the next week
        startwkMutableDateTime.addWeeks(1);
        numWeeks++;
    } while (numWeeks < 7);

    // Set up data for the monthly bar charts               
    int numMonths = 0;
    MutableDateTime startMutableDateTime = new MutableDateTime();
    MutableDateTime endMutableDateTime;
    startMutableDateTime.setDayOfMonth(1); //get the first day of the month
    startMutableDateTime.setMillisOfDay(0); //get 00:00:00 time of the day

    //go back to 6 months
    startMutableDateTime.addMonths(-5);

    do {
        //set the end date by creating a copy
        endMutableDateTime = new MutableDateTime(startMutableDateTime);
        //push it by one month
        endMutableDateTime.addMonths(1);
        //System.out.println("Start date: " + startMutableDateTime);
        //System.out.println("End date: " + endMutableDateTime);

        for (Network network : networkList) {
            //change to use millis
            count = countUtils.getIncomingCount(accountUuid, network,
                    new Date(startMutableDateTime.toDate().getTime()),
                    new Date(endMutableDateTime.toDate().getTime()));

            if (count > 0) {
                stats.addNetworkIncomingUSSDCountMonth(
                        new SimpleDateFormat("MMM").format(new Date(startMutableDateTime.getMillis())), network,
                        count);
            }

            //System.out.println(count);                            
        }
        //get the next month
        startMutableDateTime.addMonths(1);
        numMonths++;
    } while (numMonths < 6);

    return stats;
}

From source file:kr.debop4j.timeperiod.calendars.CalendarDateAdd.java

License:Apache License

@Override
public DateTime add(DateTime start, Duration offset, SeekBoundaryMode seekBoundary) {

    log.trace("add. start [{}] + offset [{}]? ?? ... seekBoundary=[{}]", start, offset,
            seekBoundary);//from   w ww . jav a 2s. c o m

    if (getWeekDays().size() == 0 && getExcludePeriods().size() == 0 && getWorkingHours().size() == 0)
        return start.plus(offset);

    Pair<DateTime, Duration> endPair = (offset.compareTo(ZERO) < 0)
            ? calculateEnd(start, Durations.negate(offset), SeekDirection.Backward, seekBoundary)
            : calculateEnd(start, offset, SeekDirection.Forward, seekBoundary);

    DateTime end = endPair.getV1();

    log.trace("add. start [{}] + offset [{}] => end=[{}] seekBoundary=[{}]", start, offset, end, seekBoundary);

    return end;
}

From source file:kr.debop4j.timeperiod.calendars.DateAdd.java

License:Apache License

/** start ? offset ?  ?? . */
public DateTime add(DateTime start, Duration offset, SeekBoundaryMode seekBoundary) {
    if (isTraceEnable)
        log.trace("Add. start=[{}] + offset=[{}]? ?? . seekBoundaryMode=[{}]", start,
                offset, seekBoundary);// w w w  .j  av  a 2  s  .c  o  m

    if (getIncludePeriods().size() == 0 && getExcludePeriods().size() == 0)
        return start.plus(offset);

    Pair<DateTime, Duration> results = offset.compareTo(Duration.ZERO) < 0
            ? calculateEnd(start, Durations.negate(offset), SeekDirection.Backward, seekBoundary)
            : calculateEnd(start, offset, SeekDirection.Forward, seekBoundary);

    DateTime end = (results != null) ? results.getV1() : null;
    Duration remaining = (results != null) ? results.getV2() : null;

    if (isDebugEnable)
        log.debug(
                "Add. start=[{}] + offset=[{}] ?  end=[{}], remaining=[{}]. seekBoundaryMode=[{}]",
                start, offset, end, remaining, seekBoundary);

    return end;
}

From source file:kr.debop4j.timeperiod.calendars.DateAdd.java

License:Apache License

/**
 *  ? offset ?  ?? ./*from   w w w  .  ja  va2s  . com*/
 *
 * @param start         ?
 * @param offset       
 * @param seekDir      ? 
 * @param seekBoundary   ? 
 * @return ? ?,  
 */
protected Pair<DateTime, Duration> calculateEnd(DateTime start, Duration offset, SeekDirection seekDir,
        SeekBoundaryMode seekBoundary) {
    if (isTraceEnable)
        log.trace(
                "? ?  ?? ... start=[{}], offset=[{}], seekDir=[{}], seekBoundary=[{}]",
                start, offset, seekDir, seekBoundary);
    shouldBe(offset.compareTo(Duration.ZERO) >= 0, "offset? 0 ??? . offset=[%d]",
            offset.getMillis());

    Duration remaining = offset;
    DateTime end;

    // search periods
    ITimePeriodCollection searchPeriods = new TimePeriodCollection(this.includePeriods);
    if (searchPeriods.size() == 0)
        searchPeriods.add(TimeRange.Anytime);

    // available periods
    ITimePeriodCollection availablePeriods = new TimePeriodCollection();
    if (excludePeriods.size() == 0) {
        availablePeriods.addAll(searchPeriods);
    } else {
        if (isTraceEnable)
            log.trace(" ? .");
        TimeGapCalculator<TimeRange> gapCalculator = new TimeGapCalculator<>();
        for (ITimePeriod p : searchPeriods) {
            if (excludePeriods.hasOverlapPeriods(p)) {
                if (isTraceEnable)
                    log.trace(" ? ?  ? ");
                for (ITimePeriod gap : gapCalculator.getGaps(excludePeriods, p))
                    availablePeriods.add(gap);
            } else {
                availablePeriods.add(p);
            }
        }
    }

    if (availablePeriods.size() == 0) {
        if (isTraceEnable)
            log.trace(" period   .");
        return Pair.create(null, remaining);
    }

    if (isTraceEnable)
        log.trace("  ? ?   ? ...");
    TimePeriodCombiner periodCombiner = new TimePeriodCombiner<TimeRange>();
    availablePeriods = periodCombiner.combinePeriods(availablePeriods);

    if (isTraceEnable)
        log.trace(" ? .");

    Pair<ITimePeriod, DateTime> result = (seekDir == SeekDirection.Forward)
            ? findNextPeriod(start, availablePeriods)
            : findPrevPeriod(start, availablePeriods);

    ITimePeriod startPeriod = result.getV1();
    DateTime seekMoment = result.getV2();

    //   ?  .
    if (startPeriod == null) {
        if (isTraceEnable)
            log.trace("  ?  .");
        return Pair.create(null, remaining);
    }

    // offset ? 0 ??,  ? ? seekMoment  .
    if (offset.isEqual(Duration.ZERO)) {
        if (isTraceEnable)
            log.trace("offset ? 0?,  ? ? seekMoment .");
        return Pair.create(seekMoment, remaining);
    }

    if (seekDir == SeekDirection.Forward) {

        for (int i = availablePeriods.indexOf(startPeriod); i < availablePeriods.size(); i++) {
            ITimePeriod gap = availablePeriods.get(i);
            Duration gapRemaining = new Duration(seekMoment, gap.getEnd());

            if (isTraceEnable)
                log.trace("Seek forward. gap=[{}], gapRemaining=[{}], remaining=[{}], seekMoment=[{}]", gap,
                        gapRemaining, remaining, seekMoment);

            boolean isTargetPeriod = (seekBoundary == SeekBoundaryMode.Fill)
                    ? gapRemaining.compareTo(remaining) >= 0
                    : gapRemaining.compareTo(remaining) > 0;

            if (isTargetPeriod) {
                end = seekMoment.plus(remaining);
                remaining = null;
                return Pair.create(end, remaining);
            }

            remaining = remaining.minus(gapRemaining);
            if (i == availablePeriods.size() - 1)
                return Pair.create(null, remaining);

            seekMoment = availablePeriods.get(i + 1).getStart(); // next period
        }
    } else {
        for (int i = availablePeriods.indexOf(startPeriod); i >= 0; i--) {
            ITimePeriod gap = availablePeriods.get(i);
            Duration gapRemaining = new Duration(gap.getStart(), seekMoment);

            if (isTraceEnable)
                log.trace("Seek backward. gap=[{}], gapRemaining=[{}], remaining=[{}], seekMoment=[{}]", gap,
                        gapRemaining, remaining, seekMoment);

            boolean isTargetPeriod = (seekBoundary == SeekBoundaryMode.Fill)
                    ? gapRemaining.compareTo(remaining) >= 0
                    : gapRemaining.compareTo(remaining) > 0;

            if (isTargetPeriod) {
                end = seekMoment.minus(remaining);
                remaining = null;
                return Pair.create(end, remaining);
            }
            remaining = remaining.minus(gapRemaining);
            if (i == 0)
                return Pair.create(null, remaining);

            seekMoment = availablePeriods.get(i - 1).getEnd();
        }
    }

    if (isTraceEnable)
        log.trace(" ??  .");
    return Pair.create(null, remaining);
}

From source file:kr.debop4j.timeperiod.test.samples.TimeBlockPeriodRelationTestData.java

License:Apache License

public TimeBlockPeriodRelationTestData(DateTime start, DateTime end, Duration duration) {

    Guard.shouldBe(duration.compareTo(Duration.ZERO) >= 0,
            "duration? 0??? ?  .");

    setReference(new TimeBlock(start, end, true));

    DateTime beforeEnd = start.minus(duration);
    DateTime beforeStart = beforeEnd.minus(reference.getDuration());
    DateTime insideStart = start.plus(duration);
    DateTime insideEnd = end.minus(duration);
    DateTime afterStart = end.plus(duration);
    DateTime afterEnd = afterStart.plus(reference.getDuration());

    after = new TimeBlock(beforeStart, beforeEnd, true);
    startTouching = new TimeBlock(beforeStart, start, true);
    startInside = new TimeBlock(beforeStart, insideStart, true);
    insideStartTouching = new TimeBlock(start, afterStart, true);
    enclosingStartTouching = new TimeBlock(start, insideEnd, true);
    enclosing = new TimeBlock(insideStart, insideEnd, true);
    enclosingEndTouching = new TimeBlock(insideStart, end, true);
    exactMatch = new TimeBlock(start, end, true);
    inside = new TimeBlock(beforeStart, afterEnd, true);
    insideEndTouching = new TimeBlock(beforeStart, end, true);
    endInside = new TimeBlock(insideEnd, afterEnd, true);
    endTouching = new TimeBlock(end, afterEnd, true);
    before = new TimeBlock(afterStart, afterEnd, true);

    allPeriods.add(reference);/*from w ww  .j a  v a2s .c om*/
    allPeriods.add(after);
    allPeriods.add(startTouching);
    allPeriods.add(startInside);
    allPeriods.add(insideStartTouching);
    allPeriods.add(enclosingStartTouching);
    allPeriods.add(enclosing);
    allPeriods.add(enclosingEndTouching);
    allPeriods.add(exactMatch);
    allPeriods.add(inside);
    allPeriods.add(insideEndTouching);
    allPeriods.add(endInside);
    allPeriods.add(endTouching);
    allPeriods.add(before);
}

From source file:kr.debop4j.timeperiod.test.samples.TimeRangePeriodRelationTestData.java

License:Apache License

public TimeRangePeriodRelationTestData(DateTime start, DateTime end, Duration duration) {
    Guard.shouldBe(duration.compareTo(Duration.ZERO) >= 0,
            "duration? 0??? ?  .");

    setReference(new TimeRange(start, end, true));

    DateTime beforeEnd = start.minus(duration);
    DateTime beforeStart = beforeEnd.minus(reference.getDuration());
    DateTime insideStart = start.plus(duration);
    DateTime insideEnd = end.minus(duration);
    DateTime afterStart = end.plus(duration);
    DateTime afterEnd = afterStart.plus(reference.getDuration());

    after = new TimeRange(beforeStart, beforeEnd, true);
    startTouching = new TimeRange(beforeStart, start, true);
    startInside = new TimeRange(beforeStart, insideStart, true);
    insideStartTouching = new TimeRange(start, afterStart, true);
    enclosingStartTouching = new TimeRange(start, insideEnd, true);
    enclosing = new TimeRange(insideStart, insideEnd, true);
    enclosingEndTouching = new TimeRange(insideStart, end, true);
    exactMatch = new TimeRange(start, end, true);
    inside = new TimeRange(beforeStart, afterEnd, true);
    insideEndTouching = new TimeRange(beforeStart, end, true);
    endInside = new TimeRange(insideEnd, afterEnd, true);
    endTouching = new TimeRange(end, afterEnd, true);
    before = new TimeRange(afterStart, afterEnd, true);

    allPeriods.add(reference);/*  w ww.  j  a v a2s .c o  m*/
    allPeriods.add(after);
    allPeriods.add(startTouching);
    allPeriods.add(startInside);
    allPeriods.add(insideStartTouching);
    allPeriods.add(enclosingStartTouching);
    allPeriods.add(enclosing);
    allPeriods.add(enclosingEndTouching);
    allPeriods.add(exactMatch);
    allPeriods.add(inside);
    allPeriods.add(insideEndTouching);
    allPeriods.add(endInside);
    allPeriods.add(endTouching);
    allPeriods.add(before);
}

From source file:kr.debop4j.timeperiod.TimeBlock.java

License:Apache License

public void setup(DateTime newStart, Duration duration) {
    assertMutable();//from   ww w  .j ava  2 s .c o m
    assertValidDuration(duration);

    log.trace("TimeBlock ?  . newStart=[{}], duration=[{}]", newStart, duration);

    this.start = newStart;
    this.duration = duration;
    this.end = newStart.plus(duration);
}

From source file:kr.debop4j.timeperiod.TimeCalendar.java

License:Apache License

@Override
public DateTime mapStart(final DateTime moment) {
    shouldNotBeNull(moment, "moment");
    return moment.compareTo(TimeSpec.MinPeriodTime) > 0 ? moment.plus(startOffset) : moment;
}