Examples of Calendar

  • gov.nysenate.openleg.model.Calendar
    @author Graylin Kim
  • java.util.Calendar
    The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of {@link #fields calendar fields} such as YEAR, MONTH,DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week. An instant in time can be represented by a millisecond value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).

    The class also provides additional fields and methods for implementing a concrete calendar system outside the package. Those fields and methods are defined as protected.

    Like other locale-sensitive classes, Calendar provides a class method, getInstance, for getting a generally useful object of this type. Calendar's getInstance method returns a Calendar object whose calendar fields have been initialized with the current date and time:

     Calendar rightNow = Calendar.getInstance(); 

    A Calendar object can produce all the calendar field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional). Calendar defines the range of values returned by certain calendar fields, as well as their meaning. For example, the first month of the calendar system has value MONTH == JANUARY for all calendars. Other values are defined by the concrete subclass, such as ERA. See individual field documentation and subclass documentation for details.

    Getting and Setting Calendar Field Values

    The calendar field values can be set by calling the set methods. Any field values set in a Calendar will not be interpreted until it needs to calculate its time value (milliseconds from the Epoch) or values of the calendar fields. Calling the get, getTimeInMillis, getTime, add and roll involves such calculation.

    Leniency

    Calendar has two modes for interpreting the calendar fields, lenient and non-lenient. When a Calendar is in lenient mode, it accepts a wider range of calendar field values than it produces. When a Calendar recomputes calendar field values for return by get(), all of the calendar fields are normalized. For example, a lenient GregorianCalendar interprets MONTH == JANUARY, DAY_OF_MONTH == 32 as February 1.

    When a Calendar is in non-lenient mode, it throws an exception if there is any inconsistency in its calendar fields. For example, a GregorianCalendar always produces DAY_OF_MONTH values between 1 and the length of the month. A non-lenient GregorianCalendar throws an exception upon calculating its time or calendar field values if any out-of-range field value has been set.

    First Week

    Calendar defines a locale-specific seven day week using two parameters: the first day of the week and the minimal days in first week (from 1 to 7). These numbers are taken from the locale resource data when a Calendar is constructed. They may also be specified explicitly through the methods for setting their values.

    When setting or getting the WEEK_OF_MONTH or WEEK_OF_YEAR fields, Calendar must determine the first week of the month or year as a reference point. The first week of a month or year is defined as the earliest seven day period beginning on getFirstDayOfWeek() and containing at least getMinimalDaysInFirstWeek() days of that month or year. Weeks numbered ..., -1, 0 precede the first week; weeks numbered 2, 3,... follow it. Note that the normalized numbering returned by get() may be different. For example, a specific Calendar subclass may designate the week before week 1 of a year as week n of the previous year.

    Calendar Fields Resolution

    When computing a date and time from the calendar fields, there may be insufficient information for the computation (such as only year and month with no day of month), or there may be inconsistent information (such as Tuesday, July 15, 1996 (Gregorian) -- July 15, 1996 is actually a Monday). Calendar will resolve calendar field values to determine the date and time in the following way.

    If there is any conflict in calendar field values, Calendar gives priorities to calendar fields that have been set more recently. The following are the default combinations of the calendar fields. The most recent combination, as determined by the most recently set single field, will be used.

    For the date fields:

     YEAR + MONTH + DAY_OF_MONTH YEAR + MONTH + WEEK_OF_MONTH + DAY_OF_WEEK YEAR + MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK YEAR + DAY_OF_YEAR YEAR + DAY_OF_WEEK + WEEK_OF_YEAR 
    For the time of day fields:
     HOUR_OF_DAY AM_PM + HOUR 

    If there are any calendar fields whose values haven't been set in the selected field combination, Calendar uses their default values. The default value of each field may vary by concrete calendar systems. For example, in GregorianCalendar, the default of a field is the same as that of the start of the Epoch: i.e., YEAR = 1970, MONTH = JANUARY, DAY_OF_MONTH = 1, etc.

    Note: There are certain possible ambiguities in interpretation of certain singular times, which are resolved in the following ways:

    1. 23:59 is the last minute of the day and 00:00 is the first minute of the next day. Thus, 23:59 on Dec 31, 1999 < 00:00 on Jan 1, 2000 < 00:01 on Jan 1, 2000.
    2. Although historically not precise, midnight also belongs to "am", and noon belongs to "pm", so on the same day, 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm

    The date or time format strings are not part of the definition of a calendar, as those must be modifiable or overridable by the user at runtime. Use {@link DateFormat}to format dates.

    Field Manipulation

    The calendar fields can be changed using three methods: set(), add(), and roll().

    set(f, value) changes calendar field f to value. In addition, it sets an internal member variable to indicate that calendar field f has been changed. Although calendar field f is changed immediately, the calendar's time value in milliseconds is not recomputed until the next call to get(), getTime(), getTimeInMillis(), add(), or roll() is made. Thus, multiple calls to set() do not trigger multiple, unnecessary computations. As a result of changing a calendar field using set(), other calendar fields may also change, depending on the calendar field, the calendar field value, and the calendar system. In addition, get(f) will not necessarily return value set by the call to the set method after the calendar fields have been recomputed. The specifics are determined by the concrete calendar class.

    Example: Consider a GregorianCalendar originally set to August 31, 1999. Calling set(Calendar.MONTH, Calendar.SEPTEMBER) sets the date to September 31, 1999. This is a temporary internal representation that resolves to October 1, 1999 if getTime()is then called. However, a call to set(Calendar.DAY_OF_MONTH, 30) before the call to getTime() sets the date to September 30, 1999, since no recomputation occurs after set() itself.

    add(f, delta) adds delta to field f. This is equivalent to calling set(f, get(f) + delta) with two adjustments:

    Add rule 1. The value of field f after the call minus the value of field f before the call is delta, modulo any overflow that has occurred in field f. Overflow occurs when a field value exceeds its range and, as a result, the next larger field is incremented or decremented and the field value is adjusted back into its range.

    Add rule 2. If a smaller field is expected to be invariant, but it is impossible for it to be equal to its prior value because of changes in its minimum or maximum after field f is changed or other constraints, such as time zone offset changes, then its value is adjusted to be as close as possible to its expected value. A smaller field represents a smaller unit of time. HOUR is a smaller field than DAY_OF_MONTH. No adjustment is made to smaller fields that are not expected to be invariant. The calendar system determines what fields are expected to be invariant.

    In addition, unlike set(), add() forces an immediate recomputation of the calendar's milliseconds and all fields.

    Example: Consider a GregorianCalendar originally set to August 31, 1999. Calling add(Calendar.MONTH, 13) sets the calendar to September 30, 2000. Add rule 1 sets the MONTH field to September, since adding 13 months to August gives September of the next year. Since DAY_OF_MONTH cannot be 31 in September in a GregorianCalendar, add rule 2 sets the DAY_OF_MONTH to 30, the closest possible value. Although it is a smaller field, DAY_OF_WEEK is not adjusted by rule 2, since it is expected to change when the month changes in a GregorianCalendar.

    roll(f, delta) adds delta to field f without changing larger fields. This is equivalent to calling add(f, delta) with the following adjustment:

    Roll rule. Larger fields are unchanged after the call. A larger field represents a larger unit of time. DAY_OF_MONTH is a larger field than HOUR.

    Example: See {@link java.util.GregorianCalendar#roll(int,int)}.

    Usage model. To motivate the behavior of add() and roll(), consider a user interface component with increment and decrement buttons for the month, day, and year, and an underlying GregorianCalendar. If the interface reads January 31, 1999 and the user presses the month increment button, what should it read? If the underlying implementation uses set(), it might read March 3, 1999. A better result would be February 28, 1999. Furthermore, if the user presses the month increment button again, it should read March 31, 1999, not March 28, 1999. By saving the original date and using either add() or roll(), depending on whether larger fields should be affected, the user interface can behave as most users will intuitively expect.

    @see java.lang.System#currentTimeMillis() @see Date @see GregorianCalendar @see TimeZone @see java.text.DateFormat @version 1.89, 08/21/08 @author Mark Davis, David Goldsmith, Chen-Lieh Huang, Alan Liu @since JDK1.1
  • net.fortuna.ical4j.model.Calendar
  • net.lalotech.struts2.map.components.Calendar
    @author Windows7x64
  • oauth.common.Calendar
  • oauth2.common.Calendar
  • org.apache.pivot.wtk.Calendar
    Component that allows the user to select a date.
  • org.drools.time.Calendar
  • org.japura.gui.calendar.Calendar

    Copyright (C) 2011-2013 Carlos Eduardo Leite de Andrade

    This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License along with this program. If not, see www.gnu.org/licenses/

    For more information, contact: www.japura.org

    @author Carlos Eduardo Leite de Andrade

  • org.jquantlib.time.Calendar
    This class provides methods for determining whether a date is a business day or a holiday for a given market, and for incrementing/decrementing a date of a given number of business days.

    A calendar should be defined for specific exchange holiday schedule or for general country holiday schedule. Legacy city holiday schedule calendars will be moved to the exchange/country convention. @author Richard Gomes

  • org.kie.api.time.Calendar
  • org.mifosplatform.portfolio.calendar.domain.Calendar
  • org.openfaces.component.calendar.Calendar
    The Calendar component enables the user to select a date from a one-month calendar and easily navigate between months and years. A specific group of dates can be included in a date range. The Calendar component can use the client's locale or a specified one. Various style options for different parts of the Calendar component let you create the desired look-and-feel. @author Kharchenko
  • org.openfeed.proto.inst.Calendar
  • org.primefaces.component.calendar.Calendar
  • org.quartz.Calendar

    An interface to be implemented by objects that define spaces of time during which an associated {@link Trigger} may fire. Calendars do not define actual fire times, but rather are used to limit a Trigger from firing on its normal schedule if necessary. Most Calendars include all times by default and allow the user to specify times to exclude. As such, it is often useful to think of Calendars as being used to exclude a block of time — as opposed to include a block of time. (i.e. the schedule "fire every five minutes except on Sundays" could be implemented with a SimpleTrigger and a WeeklyCalendar which excludes Sundays)

    Implementations MUST take care of being properly Cloneable and Serializable.

    @author James House @author Juergen Donnerstag
  • org.sgx.yuigwt.yui.widget.calendar.Calendar
    ary.com/yui/docs/api/classes/Calendar.htm @see http://yuilibrary.com/yui/docs/api/classes/CalendarBase.htm @author sg
  • org.wicketstuff.yui.markup.html.calendar.Calendar
    Calendar component based on the Calendar of Yahoo UI Library. @author Eelco Hillenius
  • org.zkoss.zul.Calendar
    A calendar.

    Default {@link #getZclass}: z-calendar. (since 3.5.0) @author tomyeh

  • org.zkoss.zul.api.Calendar
    A calendar.

    Default {@link #getZclass}: z-calendar. (since 3.5.0) @author tomyeh @since 3.5.2

  • pivot.wtk.Calendar
    Component that allows the user to select a date. @author tvolkert @author gbrown

  • Examples of java.util.Calendar

        mProgramTableScrollPane.requestFocusInWindow();
      }

      public void scrollToNow() {
        mProgramTableScrollPane.resetScrolledTime();
        Calendar cal = Calendar.getInstance();
        int hour = cal.get(Calendar.HOUR_OF_DAY);
        devplugin.Date day = new devplugin.Date();
        scrollTo(day, hour * 60 + cal.get(Calendar.MINUTE));
        mProgramTableScrollPane.requestFocusInWindow();
      }
    View Full Code Here

    Examples of java.util.Calendar

        pack();
        Settings.layoutWindow("channelConfig", this, new Dimension(420,350));
      }
     
      private void setTimeDate(JSpinner toSet, int time) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, time / 60);
        cal.set(Calendar.MINUTE, time % 60);
       
        toSet.setValue(cal.getTime());
      }
    View Full Code Here

    Examples of java.util.Calendar

       * Ensures that the field is valid date
       */
      public ActionErrors checkForDate(String fieldLabel, String yearValue, String monthValue,
          String dayValue, String errorKey, ActionErrors actionErrors)
      {
        Calendar calendar = Calendar.getInstance();
        calendar.setLenient(false);
        try {
          calendar.set(Integer.parseInt(yearValue), Integer.parseInt(monthValue), Integer.parseInt(dayValue));
        } catch (Exception e) {
          ActionMessage error = new ActionMessage(errorKey, messages.getMessage(fieldLabel));
          actionErrors.add(errorKey, error);
        }
        return actionErrors;
    View Full Code Here

    Examples of java.util.Calendar

       * @param locale the locale.
       * @return
       */
      public ActionErrors validateDateString(String fieldLabel, String date, Locale locale, String errorKey, ActionErrors actionErrors)
      {
        Calendar calendar = new GregorianCalendar();
        calendar.setLenient(false);
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
        try {
          Date parsedDate = df.parse(date);
          calendar.setTime(parsedDate);
        } catch (ParseException e) {
          ActionMessage error = new ActionMessage(errorKey, messages.getMessage(fieldLabel));
          actionErrors.add(errorKey, error);
        } catch (Exception e) {
          ActionMessage error = new ActionMessage(errorKey, messages.getMessage(fieldLabel));
    View Full Code Here

    Examples of java.util.Calendar

        HashMap headerList = new HashMap();
        HashMap headerLinkList = new HashMap();
        HashMap dateList = new HashMap();

        ArrayList calendarNavBarList = new ArrayList();
        Calendar currentCalendar = Calendar.getInstance();
        int thisDayOfMonth = currentCalendar.get(Calendar.DAY_OF_MONTH);
        int thisMonthOfYear = currentCalendar.get(Calendar.MONTH);
        String thisMonth = getCalenderMonthName(thisMonthOfYear);
        int thisYear = currentCalendar.get(Calendar.YEAR);

        if (calendarType != null && (calendarType.equals("DAILY") || calendarType.equals(""))) {
          int previousDailyDay = 0;
          String previousDailyMonth = "";
          int previousDailyYear = 0;

          if (currentDay != 0 && currentMonth >= 0 && currentYear != 0) {
            Calendar previousCalendarWeek = Calendar.getInstance();
            previousCalendarWeek.set(currentYear, currentMonth, currentDay);
            previousCalendarWeek.add(Calendar.DATE, -1);
            previousDailyDay = previousCalendarWeek.get(Calendar.DATE);
            int intYearOfMonth = previousCalendarWeek.get(Calendar.MONTH);
            previousDailyMonth = getCalenderMonthName(intYearOfMonth);
            previousDailyYear = previousCalendarWeek.get(Calendar.YEAR);
          }
          int nextDailyDay = 0;
          String nextDailyMonth = "";
          int nextDailyYear = 0;
          if (currentDay != 0 && currentMonth >= 0 && currentYear != 0) {
            Calendar nextCalendarWeek = Calendar.getInstance();
            nextCalendarWeek.set(currentYear, currentMonth, currentDay);
            nextCalendarWeek.add(Calendar.DATE, +1);
            nextDailyDay = nextCalendarWeek.get(Calendar.DATE);
            int intYearOfMonth = nextCalendarWeek.get(Calendar.MONTH);
            nextDailyYear = nextCalendarWeek.get(Calendar.YEAR);
            nextDailyMonth = getCalenderMonthName(intYearOfMonth);
          }

          StringBuffer previous = new StringBuffer();
          previous.append("c_goTo('/calendar.do?Type=DAILY&selectedDay=" + previousDailyDay);
          previous.append("&selectedMonthName=" + previousDailyMonth + "&selectedYear=" + previousDailyYear + "');");

          StringBuffer current = new StringBuffer();
          current.append("c_goTo('/calendar.do?Type=DAILY&selectedDay=" + thisDayOfMonth);
          current.append("&selectedMonthName=" + thisMonth + "&selectedYear=" + thisYear + "');");

          StringBuffer next = new StringBuffer();
          next.append("c_goTo('/calendar.do?Type=DAILY&selectedDay=" + nextDailyDay);
          next.append("&selectedMonthName=" + nextDailyMonth + "&selectedYear=" + nextDailyYear + "');");

          calendarNavBarList.add(new DDNameValue("Previous", previous.toString()));
          calendarNavBarList.add(new DDNameValue("Today", current.toString()));
          calendarNavBarList.add(new DDNameValue("Next", next.toString()));
        } else if (calendarType != null && (calendarType.equals("WEEKLY") || calendarType.equals("WEEKLYCOLUMNS"))) {
          int previousWeekDate = 0;
          String previousWeekMonth = "";
          int previousWeekYear = 0;
          if (currentDay != 0 && currentMonth >= 0 && currentYear != 0) {
            Calendar previousCalendarWeek = Calendar.getInstance();
            previousCalendarWeek.set(currentYear, currentMonth, currentDay);
            previousCalendarWeek.add(Calendar.DATE, -7);
            previousWeekDate = previousCalendarWeek.get(Calendar.DATE);
            int intYearOfMonth = previousCalendarWeek.get(Calendar.MONTH);
            previousWeekMonth = getCalenderMonthName(intYearOfMonth);
            previousWeekYear = previousCalendarWeek.get(Calendar.YEAR);
          }
          int nextWeekDay = 0;
          String nextWeekMonth = "";
          int nextWeekYear = 0;

          if (currentDay != 0 && currentMonth >= 0 && currentYear != 0) {
            Calendar nextCalendarWeek = Calendar.getInstance();
            nextCalendarWeek.set(currentYear, currentMonth, currentDay);
            nextCalendarWeek.add(Calendar.DATE, +7);
            nextWeekDay = nextCalendarWeek.get(Calendar.DATE);
            int intYearOfMonth = nextCalendarWeek.get(Calendar.MONTH);
            nextWeekYear = nextCalendarWeek.get(Calendar.YEAR);
            nextWeekMonth = getCalenderMonthName(intYearOfMonth);
          }

          StringBuffer previous = new StringBuffer();
          previous.append("c_goTo('/calendar.do?Type=" + calendarType + "&selectedDay=" + previousWeekDate);
          previous.append("&selectedMonthName=" + previousWeekMonth + "&selectedYear=" + previousWeekYear + "');");

          StringBuffer current = new StringBuffer();
          current.append("c_goTo('/calendar.do?Type=" + calendarType + "&selectedDay=" + thisDayOfMonth);
          current.append("&selectedMonthName=" + thisMonth + "&selectedYear=" + thisYear + "');");

          StringBuffer next = new StringBuffer();
          next.append("c_goTo('/calendar.do?Type=" + calendarType + "&selectedDay=" + nextWeekDay);
          next.append("&selectedMonthName=" + nextWeekMonth + "&selectedYear=" + nextWeekYear + "');");

          calendarNavBarList.add(new DDNameValue("Previous", previous.toString()));
          calendarNavBarList.add(new DDNameValue("Current Week", current.toString()));
          calendarNavBarList.add(new DDNameValue("Next", next.toString()));
          SimpleDateFormat formatter = new SimpleDateFormat("MM/dd");

          String dailyGo = "c_goTo('/calendar.do?Type=DAILY";

          if (currentDay != 0 && currentMonth >= 0 && currentYear != 0) {
            Calendar headerCalendarWeek = Calendar.getInstance();
            headerCalendarWeek.set(currentYear, currentMonth, currentDay);

            int dayOfWeek = headerCalendarWeek.get(Calendar.DAY_OF_WEEK);
            // Subtracting it with 2 coz in the Calendar Starting Day is Monday.
            int offset = dayOfWeek - 2;
            if (offset < 0) {
              int daysInWeek = 7;
              // if we are before the current day of the week, we need to fall all
              // the way back to the previous beginning of the week. calculating our
              // offset in this way will give us the right num of days to the
              // previous start. this makes it easy to just add it to the
              // currentDate.
              offset = daysInWeek + offset;
            }
            int currentDate = headerCalendarWeek.get(Calendar.DATE);
            headerCalendarWeek.set(Calendar.DATE, currentDate - offset);

            int headerDayOfMonth = headerCalendarWeek.get(Calendar.DATE);
            int headerMonthOfYear = headerCalendarWeek.get(Calendar.MONTH);
            int headerYear = headerCalendarWeek.get(Calendar.YEAR);

            try {
              // This is used in the columnar weekly view for calculating the
              // date to be filled in when you click on a empty cell.
              calendarNavBarMap.put("startDayOfWeek", new Integer(headerDayOfMonth));
            } catch (NumberFormatException nfe) {
              logger.info("[setCalendarNavBar]: The offset for the clickable weekly view boxes will probably be broken.");
              calendarNavBarMap.put("startDayOfWeek", new Integer(0));
            }

            String dateString = headerYear + ",'" + getCalenderMonthName(headerMonthOfYear) + "'," + headerDayOfMonth;
            String headerDate = formatter.format(headerCalendarWeek.getTime());
            String dailyDate = "&selectedDay=" + headerDayOfMonth + "&selectedMonthName=" + getCalenderMonthName(headerMonthOfYear) + "&selectedYear="
                + headerYear;

            String action = "ScheduleActivity(" + dateString + ",'','');";
            dateList.put(String.valueOf(0), action);
            headerLinkList.put(String.valueOf(0), dailyGo + dailyDate + "');");
            headerList.put(String.valueOf(0), headerDate);
            int count = 1;
            for (int i = 0; i < 6; i++) {
              headerCalendarWeek.add(Calendar.DATE, 1);
              headerDayOfMonth = headerCalendarWeek.get(Calendar.DAY_OF_MONTH);
              headerMonthOfYear = headerCalendarWeek.get(Calendar.MONTH);
              headerYear = headerCalendarWeek.get(Calendar.YEAR);
              dateString = headerYear + ",'" + getCalenderMonthName(headerMonthOfYear) + "'," + headerDayOfMonth;
              action = "ScheduleActivity(" + dateString + ",'','');";
              dateList.put(String.valueOf(count), action);
              headerDate = formatter.format(headerCalendarWeek.getTime());
              headerList.put(String.valueOf(count), headerDate);
              dailyDate = "&selectedDay=" + headerDayOfMonth + "&selectedMonthName=" + getCalenderMonthName(headerMonthOfYear) + "&selectedYear="
                  + headerYear;
              headerLinkList.put(String.valueOf(count), dailyGo + dailyDate + "');");
              count++;
            }
          }
        } else if (calendarType != null && calendarType.equals("MONTHLY")) {
          int previousMonthlyDay = 0;
          String previousMonthlyMonth = "";
          int previousMonthlyYear = 0;

          if (currentDay != 0 && currentMonth >= 0 && currentYear != 0) {
            Calendar previousCalendarWeek = Calendar.getInstance();
            previousCalendarWeek.set(currentYear, currentMonth, currentDay);
            previousCalendarWeek.add(Calendar.MONTH, -1);
            previousMonthlyDay = previousCalendarWeek.get(Calendar.DATE);
            int intYearOfMonth = previousCalendarWeek.get(Calendar.MONTH);
            previousMonthlyMonth = getCalenderMonthName(intYearOfMonth);
            previousMonthlyYear = previousCalendarWeek.get(Calendar.YEAR);
          }

          int nextMonthlyDay = 0;
          String nextMonthlyMonth = "";
          int nextMonthlyYear = 0;

          if (currentDay != 0 && currentMonth >= 0 && currentYear != 0) {
            Calendar nextCalendarWeek = Calendar.getInstance();
            nextCalendarWeek.set(currentYear, currentMonth, currentDay);
            nextCalendarWeek.add(Calendar.MONTH, 1);
            nextMonthlyDay = nextCalendarWeek.get(Calendar.DATE);
            int intYearOfMonth = nextCalendarWeek.get(Calendar.MONTH);
            nextMonthlyYear = nextCalendarWeek.get(Calendar.YEAR);
            nextMonthlyMonth = getCalenderMonthName(intYearOfMonth);
          }
          StringBuffer previous = new StringBuffer();
          previous.append("c_goTo('/calendar.do?Type=MONTHLY&selectedDay=" + previousMonthlyDay);
          previous.append("&selectedMonthName=" + previousMonthlyMonth + "&selectedYear=" + previousMonthlyYear + "');");
    View Full Code Here

    Examples of java.util.Calendar

          if ( start == null ) {
            start=new Date();
          }

          if ( end == null ) {
            Calendar temp = Calendar.getInstance();
            temp.setTime(new Date());
            temp.add(Constants.convertFreqNameToCalendarField(freq),interval*2);
            end = temp.getTime();
          }

          //===== WALK the dates that are described in the freq/interval.  Also fill in any
          //===== sets that are required at each level
          Calendar cur = Calendar.getInstance();
          cur.clear();
          cur.setLenient(false);
          Calendar limit = Calendar.getInstance();
          limit.clear();
          limit.setLenient(false);
          limit.setTime(end);

          //----------------- Build the year list
          cur.setTime( start );
          int val;

          if ( "YEARLY".equals(freq) ){
            //--- build by freq
            protoDateList.addAll( getFullDateValueList(Calendar.YEAR,interval,cur,limit) );
          }

          //----------------- Build the month list
          cur.setTime( start );
          if ( "MONTHLY".equals(freq) ){
            //--- build by freq
            protoDateList.addAll( getFullDateValueList(Calendar.MONTH,interval,cur,limit) );
          }
          else if ( !foundByMonth ){
            monthSet.add( new Integer( cur.get(Calendar.MONTH) ) ); // adding user fudge
          }

          //----------------- Build the day list  STILL VERY EVIL
          cur.setTime( start );
          if ( "DAILY".equals(freq) ){
            //--- build by freq
            protoDateList.addAll( getFullDateValueList(Calendar.DAY_OF_MONTH,interval,cur,limit) );
          }
          else if ( !foundByDay && !foundByWeekNo && !foundByMonthDay && !foundByYearDay ){
            monthDaySet.add( new Integer( cur.get(Calendar.DAY_OF_MONTH) ) );
          }

          //----------------- Build the week list
          cur.setTime( start );
          if ( "WEEKLY".equals(freq) ){
            //--- build by freq
            protoDateList.addAll( getFullDateValueList(Calendar.WEEK_OF_YEAR,interval,cur,limit) );
            if ( !foundByDay ){
              weekDaySet.add( new ByDay(0,Constants.convertDayNumberToDayName(cur.get(Calendar.DAY_OF_WEEK)) ) );
            }
          }
          //--- the week from original date is not taken as a default


          //----------------- Build the hour list
          cur.setTime( start );
          if ( "HOURLY".equals(freq) ){
            //--- build by freq
            protoDateList.addAll( getFullDateValueList(Calendar.HOUR_OF_DAY,interval,cur,limit) );
          }
          else if ( !foundByHour ){
            hourSet.add( new Integer( cur.get(Calendar.HOUR_OF_DAY) ) );
          }

          //----------------- Build the minute list
          cur.setTime( start );
          if ( "MINUTELY".equals(freq) ){
            //--- build by freq
            protoDateList.addAll( getFullDateValueList(Calendar.MINUTE,interval,cur,limit) );
          }
          else if ( !foundByMinute ){
            minSet.add( new Integer( cur.get(Calendar.MINUTE) ) );
          }

          //----------------- Build the second list
          cur.setTime( start );
          if ( "SECONDLY".equals(freq) ){
            //--- build by freq
            protoDateList.addAll( getFullDateValueList(Calendar.SECOND,interval,cur,limit) );
          }
          else if ( !foundBySecond ){
            secSet.add( new Integer( cur.get(Calendar.SECOND) ) );
          }


          resultList = new ArrayList();
          Calendar result = Calendar.getInstance();
          result.setLenient(false);
          result.clear();

    /*
          if ( TestRecurrance.debug ){
            println("pS   "+protoDateList.size());
            println("yS   "+yearSet.size()+"  "+yearSet);
            println("mS   "+monthSet.size()+"  "+monthSet);
            println("mDS  "+monthDaySet.size()+"  "+monthDaySet);
            println("wDS  "+weekDaySet.size()+"  "+weekDaySet);
            println("hS   "+hourSet.size()+"  "+hourSet);
            println("minS "+minSet.size()+"  "+minSet);
            println("sS   "+secSet.size()+"  "+secSet);
          }
    */

          //===== CULL the dates that are not acceptable to BYxyz commands which are of a higher
          //===== magnitude than the frequency
          int freqNumber = Constants.convertFreqNameToFreqNumber(freq);

          for ( int pdCtr = protoDateList.size()-1 ; pdCtr>=0 ; pdCtr-- ){
            Calendar curProtoDate = (Calendar)protoDateList.get(pdCtr);

            // BYMONTH
            if ( foundByMonth && freqNumber <= Constants.FREQ_MONTHLY ){
              if ( ! isDateInMetaSet(curProtoDate,Calendar.MONTH,monthSet) ){
                println("remove by month");
                protoDateList.remove(pdCtr);
                continue;
              }
            }
            // BYWEEKNO
            if ( foundByWeekNo && freqNumber <= Constants.FREQ_WEEKLY ){
              if ( ! isDateInMetaSet(curProtoDate,Calendar.WEEK_OF_YEAR,weekNumberSet) ){
                println("remove by week no");
                protoDateList.remove(pdCtr);
                continue;
              }
            }
            // BYYEARDAY
            if ( foundByYearDay && freqNumber <= Constants.FREQ_DAILY ){
              if ( ! isDateInMetaSet(curProtoDate,Calendar.DAY_OF_YEAR,yearDaySet) ){
                println("remove by year day");
                protoDateList.remove(pdCtr);
                continue;
              }
            }
            // BYMONTHDAY
            if ( foundByMonthDay && freqNumber <= Constants.FREQ_DAILY ){
              if ( ! isDateInMetaSet(curProtoDate,Calendar.DAY_OF_MONTH,monthDaySet) ){
                println("remove by month day");
                protoDateList.remove(pdCtr);
                continue;
              }
            }
            // BYDAY - Deeply Evil
            if ( foundByDay && freqNumber <= Constants.FREQ_DAILY ){
              if ( ! isDateInWeekDayMetaSet(curProtoDate,Calendar.DAY_OF_MONTH,weekDaySet) ){
                println("remove by month day");
                protoDateList.remove(pdCtr);
                continue;
              }
            }
            // BYHOUR
            if ( foundByHour && freqNumber <= Constants.FREQ_HOURLY ){
              if ( ! isDateInMetaSet(curProtoDate,Calendar.HOUR_OF_DAY,hourSet) ){
                println("remove by hour");
                protoDateList.remove(pdCtr);
                continue;
              }
            }
            // BYMINUTE
            if ( foundByMinute && freqNumber <= Constants.FREQ_MINUTELY ){
              if ( ! isDateInMetaSet(curProtoDate,Calendar.MINUTE,minSet) ){
                println("remove by minute");
                protoDateList.remove(pdCtr);
                continue;
              }
            }
          }

          //===== SPEW in the dates that are added by using a BYxyz of lower
          //===== magnitude than the frequency

          HashSet resultSet = new HashSet();

          for ( int pdCtr = protoDateList.size()-1 ; pdCtr>=0 ; pdCtr-- ){
            Calendar curProtoDate = (Calendar)protoDateList.get(pdCtr);

            HashSet resultPile = new HashSet();
            resultPile.add(curProtoDate);

            // BYMONTH
            if ( freqNumber > Constants.FREQ_MONTHLY ){
              resultPile = breedMetaSet(resultPile,Calendar.MONTH,monthSet);
            }

            // BYWEEKNO
            if ( freqNumber > Constants.FREQ_WEEKLY ){
              resultPile = breedMetaSet(resultPile,Calendar.WEEK_OF_YEAR,weekNumberSet);
            }
            // BYYEARDAY
            if ( freqNumber > Constants.FREQ_DAILY && freqNumber != Constants.FREQ_WEEKLY ){
              resultPile = breedMetaSet(resultPile,Calendar.DAY_OF_YEAR,yearDaySet);
            }
            // BYMONTHDAY
            if ( freqNumber > Constants.FREQ_DAILY && freqNumber != Constants.FREQ_WEEKLY ){
              resultPile = breedMetaSet(resultPile,Calendar.DAY_OF_MONTH,monthDaySet);
            }
            // BYDAY - Deeply Evil
            if ( freqNumber > Constants.FREQ_DAILY                  /*&& freqNumber != Constants.FREQ_WEEKLY*/ ){
              resultPile = breedWeekDayMetaSet(resultPile,weekDaySet);
            }
            // BYHOUR
            if ( freqNumber > Constants.FREQ_HOURLY ){
              resultPile = breedMetaSet(resultPile,Calendar.HOUR_OF_DAY,hourSet);
            }
            // BYMINUTE
            if ( freqNumber > Constants.FREQ_MINUTELY ){
              resultPile = breedMetaSet(resultPile,Calendar.MINUTE,minSet);
            }
            // BYSECOND
            if ( freqNumber > Constants.FREQ_SECONDLY ){
              resultPile = breedMetaSet(resultPile,Calendar.SECOND,secSet);
            }

            resultSet.addAll(resultPile);
          }

          println("pS pb "+resultSet.size());

          //--- convert the calendar objects into date objects
          for ( Iterator rsIt = resultSet.iterator(); rsIt.hasNext() ; ){
            Calendar c = (Calendar)rsIt.next();
            resultList.add(c.getTime());
          }


          Collections.sort(resultList);

          //===== ENSURE the limitation on the primary dates
          //--- ensure the bounds
          for ( int rctr=resultList.size()-1;rctr>=0;rctr-- ){
            Date curDate = (Date)resultList.get(rctr);
            if ( ! ( (curDate.before(end) || curDate.equals(end)) &&
                     (curDate.after(start) || curDate.equals(start)) ) ){
              resultList.remove(rctr);
            }
          }
    /*
          if ( TestRecurrance.debug ){
            println("rS "+resultList.size());
          }
    */
          //===== FILTER the dates returned
          //--- apply the BYSETPOS filter by examining the dates for each recurrance and culling appropriately
          //--- note that finalList MUST be sorted for this to work.
          resultList = (ArrayList)filterUsingBySetPos(resultList, bspSet, Constants.convertFreqNameToCalendarField(freq) );

          //--- apply the OFFSET filter by altering each date as requested.  NOTE:  This may take dates outside
          //      the start and end range.  (I.E. you'll want a meeting reminder before the start of the first
          //      meeting)



          //--- ensure the count
          List finalList;
          if ( count != 0 && resultList.size() > count ){
            finalList = (List)resultList.subList(0,count);
          }
          else{
            finalList = resultList;
          }

          //==== MODIFY the dates returned using OFFSET
          if( offsetAmount != 0 ){
            Calendar modificationTool = Calendar.getInstance();
            for(int ctr=0;ctr<finalList.size();ctr++){
              Date curMod = (Date)finalList.get(ctr);
              modificationTool.setTime(curMod);
              modificationTool.add(offsetUnit, offsetAmount);
              curMod = modificationTool.getTime();
              finalList.set(ctr,curMod);
            }

          }

    View Full Code Here

    Examples of java.util.Calendar

      @param cur the start of the range
      @param end the end of the range.
      ***/
      private List getValueList(int unit, int interval, Calendar inputCur, Calendar inputEnd)
      {
        Calendar cur = roundDown(unit,(Calendar)inputCur.clone());
        Calendar end = roundDown(unit,(Calendar)inputEnd.clone());

        int val = cur.get(unit);

        ArrayList resultList = new ArrayList();
        //println("val "+val);
        resultList.add(new Integer(val));

        cur.add(unit, interval);

        while ( cur.getTime().before(end.getTime()) ||
                cur.getTime().equals(end.getTime()) ){              // while not past the end date
          val = cur.get(unit);
          //println("val "+val);
          resultList.add(new Integer(val));
          cur.add(unit, interval);
        }
    View Full Code Here

    Examples of java.util.Calendar

      @param cur the start of the range
      @param end the end of the range.
      ***/
      private List getFullDateValueList(int unit, int interval, Calendar inputCur, Calendar inputEnd)
      {
        Calendar cur = roundDown(unit,(Calendar)inputCur.clone());
        Calendar end = roundDown(unit,(Calendar)inputEnd.clone());

        println("Round Down  "+cur.getTime());
        println("Round Up    "+end.getTime());
        //int val = cur.get(unit);

        ArrayList resultList = new ArrayList();
        resultList.add( cur.clone() );
        println("val "+cur.getTime());

        cur.add(unit, interval);

        while ( cur.getTime().before(end.getTime()) ||
                cur.getTime().equals(end.getTime()) ){              // while not past the end date
          println("val "+cur.getTime());
          resultList.add( cur.clone() );
          cur.add(unit, interval);
        }

    View Full Code Here

    Examples of java.util.Calendar

      @param unRounded a calendar value
      @return a rounded calendar value
      ***/
      private Calendar roundDown(int unit,Calendar unRounded)
      {
        Calendar result = (Calendar)unRounded.clone();
        //println("pre "+result.getTime());

        if ( unit < Calendar.YEAR ) result.set(Calendar.YEAR,0);
        if ( unit < Calendar.MONTH ) result.set(Calendar.MONTH,0);
        if ( unit < Calendar.DAY_OF_MONTH ) result.set(Calendar.DAY_OF_MONTH,1);
        if ( unit < Calendar.HOUR_OF_DAY ) result.set(Calendar.HOUR_OF_DAY,0);
        if ( unit < Calendar.MINUTE ) result.set(Calendar.MINUTE,0);
        if ( unit < Calendar.SECOND ) result.set(Calendar.SECOND,0);

        if ( unit == Calendar.WEEK_OF_YEAR ) result.set(Calendar.WEEK_OF_YEAR,unRounded.get(Calendar.WEEK_OF_YEAR));

        //println("post "+result.getTime());
        return result;
      }
    View Full Code Here

    Examples of java.util.Calendar

            if ( curProtoDate.get(Calendar.DAY_OF_WEEK) == Constants.convertDayNameToDayNumber(bd.weekday) ){
              return true;
            }
          }
          else{
            Calendar hunter = huntDayOfWeek(curProtoDate, bd);
            if ( hunter.get(Calendar.DAY_OF_YEAR) == curProtoDate.get(Calendar.DAY_OF_YEAR) ){
              return true;
            }
          }
        }
        //--- we can only get here if none of the previous items matched and returned true.
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. 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.