コード例 #1
0
  public DemoCalendarActivityBean(
      DemoCalendarActivity activity, TimeZone tz, DemoCalendarModelWrapper model) {
    _tz = tz;
    _activity = activity;
    _model = model;

    _allDay = (CalendarActivity.TimeType.ALLDAY.equals(_activity.getTimeType()));

    if (CalendarActivity.TimeType.DURATION.equals(_activity.getTimeType())) {
      long duration = _activity.getDuration(_activity.getStartDate(tz), tz);
      _durHours = Integer.valueOf((int) (duration / _SIXTY_MINUTES_IN_MILLIS));
      _durMinutes =
          Integer.valueOf(
              (int) ((duration - _durHours * _SIXTY_MINUTES_IN_MILLIS) / _SIXTY_SECONDS_IN_MILLIS));
    }
  }
コード例 #2
0
  /**
   * Gets the total duration of the TimeType.DURATION activity by summing up durations reported
   * against individual dates between activity start and end date (exclusive)
   *
   * @param activity
   * @param tz
   * @return
   */
  private long _getTotalActivityDuration(CalendarActivity activity, TimeZone tz) {
    if (!CalendarActivity.TimeType.DURATION.equals(activity.getTimeType())) return 0L;

    long totalDuration = 0L;

    Calendar activeCal = Calendar.getInstance(tz);
    activeCal.setTime(activity.getStartDate(tz));

    Calendar endCal = Calendar.getInstance(tz);
    endCal.setTime(activity.getEndDate(tz));

    do {
      totalDuration += Math.max(0, activity.getDuration(activeCal.getTime(), tz));

      // increment the calendar
      activeCal.add(Calendar.DAY_OF_YEAR, 1);
    } while (activeCal.before(endCal));

    return totalDuration;
  }
コード例 #3
0
 public boolean isDuration() {
   return CalendarActivity.TimeType.DURATION.equals(_activity.getTimeType());
 }