Package org.projectforge.common

Examples of org.projectforge.common.DateHolder


    final String s = "select distinct location from "
        + clazz.getSimpleName()
        + " t where deleted=false and t.calendar in :cals and lastUpdate > :lastUpdate and lower(t.location) like :location) order by t.location";
    final Query query = getSession().createQuery(s);
    query.setParameterList("cals", calendars);
    final DateHolder dh = new DateHolder();
    dh.add(Calendar.YEAR, -1);
    query.setDate("lastUpdate", dh.getDate());
    query.setString("location", "%" + StringUtils.lowerCase(searchString) + "%");
    final List<String> list = query.list();
    return list;
  }
View Full Code Here


      }

      @Override
      public void validate(final Form< ? > form)
      {
        final DateHolder startDate = new DateHolder(startDateTimePanel.getConvertedInput());
        final DateHolder endDate = new DateHolder(endDateTimePanel.getConvertedInput());
        data.setStartDate(startDate.getTimestamp());
        data.setEndDate(endDate.getTimestamp());
        if (data.getDuration() < 60000) {
          // Duration is less than 60 seconds.
          error(getString("plugins.teamcal.event.duration.error"));
        }
      }
View Full Code Here

   * @param cal
   * @param month
   */
  public WeekHolder(Calendar cal, int month)
  {
    DateHolder dateHolder = new DateHolder(cal, DatePrecision.DAY);
    weekOfYear = DateHelper.getWeekOfYear(cal);
    dateHolder.setBeginOfWeek();
    dateHolder.computeTime();
    days = new DayHolder[7];
    // Process week
    for (int i = 0; i < 7; i++) {
      DayHolder day = new DayHolder(dateHolder);
      if (day.getMonth() != month) {
        // Mark this day as day from the previous or next month:
        day.setMarker(true);
      }
      days[i] = day;
      dateHolder.add(Calendar.DAY_OF_YEAR, 1);
    }
  }
View Full Code Here

  {
    this.address = address;
    if (address.getBirthday() == null) {
      throw new UnsupportedOperationException("Birthday not given!");
    }
    final DateHolder day = new DateHolder(address.getBirthday());
    month = day.getMonth();
    dayOfMonth = day.getDayOfMonth();
    dateOfYear = getDateOfYear(month, dayOfMonth);
    compareString = dateOfYear + " " + address.getName() + ", " + address.getFirstName();
  }
View Full Code Here

  }

  /** Sets and gets the age of the person at the given date. */
  public int setAge(final Date date)
  {
    final DateHolder dh = new DateHolder(date);
    final DateHolder birthday = new DateHolder(address.getBirthday());
    age = dh.getYear() - birthday.getYear();
    return age;
  }
View Full Code Here

  public static String getDateOfYear(final Date date)
  {
    if (date == null) {
      throw new UnsupportedOperationException("Date not given!");
    }
    final DateHolder dh = new DateHolder(date);
    return getDateOfYear(dh.getMonth(), dh.getDayOfMonth());
  }
View Full Code Here

    filter.add(Restrictions.isNotNull("birthday"));
    final List<AddressDO> list = getList(filter);
    // Uses not Collections.sort because every comparison needs Calendar.getDayOfYear().
    final Set<BirthdayAddress> set = new TreeSet<BirthdayAddress>();
    final Set<Integer> favorites = getFavorites();
    final DateHolder from = new DateHolder(fromDate);
    final DateHolder to = new DateHolder(toDate);
    DateHolder dh;
    final int fromMonth = from.getMonth();
    final int fromDayOfMonth = from.getDayOfMonth();
    final int toMonth = to.getMonth();
    final int toDayOfMonth = to.getDayOfMonth();
    for (final AddressDO address : list) {
      if (all == false && favorites.contains(address.getId()) == false) {
        // Address is not a favorite address, so ignore it.
        continue;
      }
      dh = new DateHolder(address.getBirthday());
      final int month = dh.getMonth();
      final int dayOfMonth = dh.getDayOfMonth();
      if (DateHelper.dateOfYearBetween(month, dayOfMonth, fromMonth, fromDayOfMonth, toMonth, toDayOfMonth) == false) {
        continue;
      }
      final BirthdayAddress ba = new BirthdayAddress(address);
      if (favorites.contains(address.getId()) == true) {
View Full Code Here

    if (src.getReminderActionType() != null && src.getReminderDuration() != null && src.getReminderDurationUnit() != null) {
      event.setReminderType(src.getReminderActionType().toString());
      event.setReminderDuration(src.getReminderDuration());
      final ReminderDurationUnit unit = src.getReminderDurationUnit();
      event.setReminderUnit(unit.toString());
      final DateHolder date = new DateHolder(src.getStartDate());
      if (unit == ReminderDurationUnit.MINUTES) {
        date.add(Calendar.MINUTE, -src.getReminderDuration());
        event.setReminder(date.getDate());
      } else if (unit == ReminderDurationUnit.HOURS) {
        date.add(Calendar.HOUR, -src.getReminderDuration());
        event.setReminder(date.getDate());
      } else if (unit == ReminderDurationUnit.DAYS) {
        date.add(Calendar.DAY_OF_YEAR, -src.getReminderDuration());
        event.setReminder(date.getDate());
      } else {
        log.warn("ReminderDurationUnit '" + src.getReminderDurationUnit() + "' not yet implemented.");
      }
    }
  }
View Full Code Here

  public void select(final String property, final Object selectedValue)
  {
    if (property.startsWith("quickSelect.") == true) { // month".equals(property) == true) {
      final Date date = (Date) selectedValue;
      form.getSearchFilter().setStartDate(date);
      final DateHolder dateHolder = new DateHolder(date);
      if (property.endsWith(".month") == true) {
        dateHolder.setEndOfMonth();
      } else if (property.endsWith(".week") == true) {
        dateHolder.setEndOfWeek();
      } else {
        log.error("Property '" + property + "' not supported for selection.");
      }
      form.getSearchFilter().setEndDate(dateHolder.getDate());
      form.startDate.markModelAsChanged();
      form.endDate.markModelAsChanged();
      refresh();
    } else {
      super.select(property, selectedValue);
View Full Code Here

    calculate();
  }

  private void calculate()
  {
    final DateHolder dateHolder = new DateHolder(cal, DatePrecision.DAY);
    year = dateHolder.getYear();
    month = dateHolder.getMonth();
    dateHolder.setBeginOfMonth();
    begin = dateHolder.getDate(); // Storing begin of month.
    dateHolder.setEndOfMonth();
    end = dateHolder.getDate(); // Storing end of month.
    dateHolder.setDate(begin); // reset to begin of month
    dateHolder.computeTime();
    dateHolder.setBeginOfWeek(); // get first week (with days of previous month)

    weeks = new ArrayList<WeekHolder>();
    do {
      final WeekHolder week = new WeekHolder(dateHolder.getCalendar(), month);
      weeks.add(week);
      dateHolder.add(Calendar.WEEK_OF_YEAR, 1);
    } while (dateHolder.getMonth() == month);
  }
View Full Code Here

TOP

Related Classes of org.projectforge.common.DateHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.