<p>
Determine the next time (in milliseconds) that is 'included' by the
Calendar after the given time.
</p>
<p>
Note that this Calendar is only has full-day precision.
</p>
358335
@Override
  public long getNextIncludedTime (final long nTimeStamp)
  {

    // Call base calendar implementation first
    long timeStamp = nTimeStamp;
    final long baseTime = super.getNextIncludedTime (timeStamp);
    if ((baseTime > 0) && (baseTime > timeStamp))
    {
      timeStamp = baseTime;
    }

    // Get timestamp for 00:00:00
    final Calendar day = getStartOfDayJavaCalendar (timeStamp);
    while (isTimeIncluded (day.getTime ().getTime ()) == false)
    {
      day.add (Calendar.DATE, 1);
    }

    return day.getTime ().getTime ();
  }
408485
private boolean isTimeAfterOrEquals(Calendar time1, Calendar time2) {
        return !(time1 == null || time2 == null) && time1.getTimeInMillis() >= time2.getTimeInMillis();
    }
367409
private void onEnd()
   {
      long result = System.currentTimeMillis() - currentTime.get().poll();
      times.incrementAndGet();
      if (result < min.get())
      {
         min.set(result);
      }
      if (max.get() < result)
      {
         max.set(result);
      }
      total.addAndGet(result);
   }
1355167
@Override
  public Date getFireTimeAfter (@Nullable final Date aAfterTime)
  {
    if (m_bComplete)
      return null;

    if ((m_nTimesTriggered > m_nRepeatCount) && (m_nRepeatCount != REPEAT_INDEFINITELY))
      return null;

    Date afterTime = aAfterTime;
    if (afterTime == null)
      afterTime = new Date ();

    if (m_nRepeatCount == 0 && afterTime.compareTo (getStartTime ()) >= 0)
      return null;

    final long startMillis = getStartTime ().getTime ();
    final long afterMillis = afterTime.getTime ();
    final long endMillis = (getEndTime () == null) ? Long.MAX_VALUE : getEndTime ().getTime ();

    if (endMillis <= afterMillis)
      return null;

    if (afterMillis < startMillis)
      return new Date (startMillis);

    final long numberOfTimesExecuted = ((afterMillis - startMillis) / m_nRepeatInterval) + 1;

    if ((numberOfTimesExecuted > m_nRepeatCount) && (m_nRepeatCount != REPEAT_INDEFINITELY))
      return null;

    final Date time = new Date (startMillis + (numberOfTimesExecuted * m_nRepeatInterval));
    if (endMillis <= time.getTime ())
      return null;
    return time;
  }
338401
def include? date_time
      return false unless date_time.is_a?(String) || date_time.is_a?(DateTime)

      if date_time.is_a?(String)
        date_precision = Helper.determine_date_precision_of date_time
        date_time = Helper.date_time_from date_time, date_precision
      end

      result, = @data.bsearch { |d| d[0] >= date_time }
      result && result == date_time
    end
127754
private boolean advanceDayIfNeeded(Calendar cal)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        // Try all of the different mechanisms for matching a day, but only if
        // they are not wild cards.  If one of the "getNext" methods returns
        // the current day, then we are done.  Otherwise, each method will
        // have returned the nearest day of the current month that would
        // satisfy the constraint, or a number >= the last day of the month to
        // indicate there are no matching days this month.  The
        // ADVANCE_TO_NEXT_MONTH constant is defined for convenience.

        int day = cal.get(Calendar.DAY_OF_MONTH) - 1;
        int nextDay = Integer.MAX_VALUE;

        if (daysOfMonth != WILD_CARD)
        {
            int result = getNextDayOfMonth(day);

            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "next dayOfMonth = " + result);

            if (result == day)
            {
                return false;
            }

            nextDay = Math.min(nextDay, result);
        }

        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH) - 1;

        if (lastDaysOfMonth != WILD_CARD)
        {
            int result = getNextLastDayOfMonth(day, lastDay);

            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "next lastDayOfMonth = " + result);

            if (result == day)
            {
                return false;
            }

            nextDay = Math.min(nextDay, result);
        }

        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK) - 1;

        if (daysOfWeek != WILD_CARD)
        {
            int result = getNextDayOfWeek(day, dayOfWeek);

            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "next daysOfWeek = " + result);

            if (result == day)
            {
                return false;
            }

            nextDay = Math.min(nextDay, result);
        }

        if (daysOfWeekInMonth != WILD_CARD)
        {
            int result = getNextDayOfWeekInMonth(day, lastDay, dayOfWeek);

            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "daysOfWeekInMonth includes " + result);

            if (result == day)
            {
                return false;
            }

            nextDay = Math.min(nextDay, result);
        }

        if (lastDaysOfWeekInMonth != WILD_CARD)
        {
            int result = getNextLastDayOfWeekInMonth(day, lastDay, dayOfWeek);

            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "next lastDaysOfWeekInMonth = " + result);

            if (result == day)
            {
                return false;
            }

            nextDay = Math.min(nextDay, result);
        }

        if (variableDayOfMonthRanges != null) // d659945
        {
            int result = getNextVariableDay(day, lastDay, dayOfWeek);

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "next variableDayOfMonthRanges = " + result);

            if (result == day)
            {
                return false;
            }

            nextDay = Math.min(nextDay, result);
        }

        if (nextDay == Integer.MAX_VALUE)
        {
            // No day constraints are specified for this expression.
            return false;
        }

        // d659945.1 - Reset fields using firstOfWildCard.
        cal.set(Calendar.SECOND, firstOfWildCard(seconds));
        cal.set(Calendar.MINUTE, firstOfWildCard(minutes));
        cal.set(Calendar.HOUR_OF_DAY, firstOfWildCard(hours));

        if (nextDay <= lastDay)
        {
            // A constraint matched a day within the current month.
            cal.set(Calendar.DAY_OF_MONTH, nextDay + 1);
        }
        else
        {
            // There were no matches for the rest of the days in the current
            // month.  Advance to the next month and try again.
            cal.set(Calendar.DAY_OF_MONTH, 1);
            cal.add(Calendar.MONTH, 1);
        }

        return true;
    }
818896
public long toMilliseconds() {
        final Date now = new Date();
        return TimeCategory.minus(plus(now), now).toMilliseconds();
    }
674586
@Override
  public boolean isTimeIncluded (final long timeInMillis)
  {
    if (getBaseCalendar () != null && !getBaseCalendar ().isTimeIncluded (timeInMillis))
    {
      return false;
    }

    return !m_aCronExpression.isSatisfiedBy (new Date (timeInMillis));
  }
795610
public static boolean after(final Date point, final Date when)
	{
		final Calendar pointCalendar = Calendar.getInstance();
		pointCalendar.setTime(point);
		final Calendar whenCalendar = Calendar.getInstance();
		whenCalendar.setTime(when);
		return pointCalendar.after(whenCalendar);
	}
566749
public long getSunTime(double desired, boolean next)
    {
        return timeOfAngle( new AngleFunc() { @Override
        public double eval() { return getSunLongitude(); } },
                            desired,
                            TROPICAL_YEAR,
                            MINUTE_MS,
                            next);
    }
845465
public boolean after(JKTimeObject thareTime) {
		if (getYear() == thareTime.getYear() || thareTime.getYear() > getYear()) {
			System.out.println("after:: Year true");
			if (thareTime.getMonth() < getMonth()) {
				return true;
			}
			if (getMonth() == thareTime.getMonth()) {
				System.out.println("after:: Month true");
				if (thareTime.getDay() < getDay()) {
					System.out.println("after:: Day true");
					return true;
				}
				if (getDay() == thareTime.getDay()) {
					if (getHour() == thareTime.getHour()) {
						if (thareTime.getMunite() < getMunite()) {
							return true;
						}
					}
					if (getHour() > thareTime.getHour()) {
						return true;
					}
				}
			}
		}
		return false;

	}
182776
private Date getTimeFromInteger(Integer time)
   {
      Date result = null;

      if (time != null)
      {
         int minutes = time.intValue();
         int hours = minutes / 60;
         minutes -= (hours * 60);

         Calendar cal = DateHelper.popCalendar();
         cal.set(Calendar.MILLISECOND, 0);
         cal.set(Calendar.SECOND, 0);
         cal.set(Calendar.MINUTE, minutes);
         cal.set(Calendar.HOUR_OF_DAY, hours);
         result = cal.getTime();
         DateHelper.pushCalendar(cal);
      }

      return (result);
   }
1162033
def include?(timestamp)
      return false if earlier?(timestamp) || later?(timestamp)

      recurrence = finite? ? self : starts(timestamp)

      recurrence.events.lazy.each do |event|
        return true if event == timestamp
        return false if event > timestamp
      end or false
    end
271766
public static int[] getElapsedTime(Date first, Date second) {
         if (first.compareTo(second) == 1 ) {
            return null;
         }
         int difDays = 0;
         int difHours = 0;
         int difMinutes = 0;

         Calendar c = Calendar.getInstance();
         c.setTime(first);
         int h1 = c.get(Calendar.HOUR_OF_DAY);
         int m1 = c.get(Calendar.MINUTE);

         c.setTime(second);
         int h2 = c.get(Calendar.HOUR_OF_DAY);
         int m2 = c.get(Calendar.MINUTE);

         if (sameDay(first, second)) {
             difHours = h2 - h1;
         } else {
             difDays = getNumberOfDays(first, second)-1;
             if (h1 >= h2) {
                difDays--;
                difHours = (24 - h1) + h2;
             } else {
                difHours = h2 - h1;
             }
         }

         if (m1 >= m2) {
             difHours--;
             difMinutes = (60 - m1) + m2;
         } else {
             difMinutes = m2 - m1;
         }

         int[] result = new int[3];
         result[0] = difDays;
         result[1] = difHours;
         result[2] = difMinutes;
         return result;
     }
520063
@Override
    protected void computeTime() {
        // In non-lenient mode, perform brief checking of calendar
        // fields which have been set externally. Through this
        // checking, the field values are stored in originalFields[]
        // to see if any of them are normalized later.
        if (!isLenient()) {
            if (originalFields == null) {
                originalFields = new int[FIELD_COUNT];
            }
            for (int field = 0; field < FIELD_COUNT; field++) {
                int value = internalGet(field);
                if (isExternallySet(field)) {
                    // Quick validation for any out of range values
                    if (value < getMinimum(field) || value > getMaximum(field)) {
                        throw new IllegalArgumentException(getFieldName(field));
                    }
                }
                originalFields[field] = value;
            }
        }

        // Let the super class determine which calendar fields to be
        // used to calculate the time.
        int fieldMask = selectFields();

        // The year defaults to the epoch start. We don't check
        // fieldMask for YEAR because YEAR is a mandatory field to
        // determine the date.
        int year = isSet(YEAR) ? internalGet(YEAR) : EPOCH_YEAR;

        int era = internalGetEra();
        if (era == BCE) {
            year = 1 - year;
        } else if (era != CE) {
            // Even in lenient mode we disallow ERA values other than CE & BCE.
            // (The same normalization rule as add()/roll() could be
            // applied here in lenient mode. But this checking is kept
            // unchanged for compatibility as of 1.5.)
            throw new IllegalArgumentException("Invalid era");
        }

        // If year is 0 or negative, we need to set the ERA value later.
        if (year <= 0 && !isSet(ERA)) {
            fieldMask |= ERA_MASK;
            setFieldsComputed(ERA_MASK);
        }

        // Calculate the time of day. We rely on the convention that
        // an UNSET field has 0.
        long timeOfDay = 0;
        if (isFieldSet(fieldMask, HOUR_OF_DAY)) {
            timeOfDay += (long) internalGet(HOUR_OF_DAY);
        } else {
            timeOfDay += internalGet(HOUR);
            // The default value of AM_PM is 0 which designates AM.
            if (isFieldSet(fieldMask, AM_PM)) {
                timeOfDay += 12 * internalGet(AM_PM);
            }
        }
        timeOfDay *= 60;
        timeOfDay += internalGet(MINUTE);
        timeOfDay *= 60;
        timeOfDay += internalGet(SECOND);
        timeOfDay *= 1000;
        timeOfDay += internalGet(MILLISECOND);

        // Convert the time of day to the number of days and the
        // millisecond offset from midnight.
        long fixedDate = timeOfDay / ONE_DAY;
        timeOfDay %= ONE_DAY;
        while (timeOfDay < 0) {
            timeOfDay += ONE_DAY;
            --fixedDate;
        }

        // Calculate the fixed date since January 1, 1 (Gregorian).
        calculateFixedDate: {
            long gfd, jfd;
            if (year > gregorianCutoverYear && year > gregorianCutoverYearJulian) {
                gfd = fixedDate + getFixedDate(gcal, year, fieldMask);
                if (gfd >= gregorianCutoverDate) {
                    fixedDate = gfd;
                    break calculateFixedDate;
                }
                jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask);
            } else if (year < gregorianCutoverYear && year < gregorianCutoverYearJulian) {
                jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask);
                if (jfd < gregorianCutoverDate) {
                    fixedDate = jfd;
                    break calculateFixedDate;
                }
                gfd = jfd;
            } else {
                jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask);
                gfd = fixedDate + getFixedDate(gcal, year, fieldMask);
            }

            // Now we have to determine which calendar date it is.

            // If the date is relative from the beginning of the year
            // in the Julian calendar, then use jfd;
            if (isFieldSet(fieldMask, DAY_OF_YEAR) || isFieldSet(fieldMask, WEEK_OF_YEAR)) {
                if (gregorianCutoverYear == gregorianCutoverYearJulian) {
                    fixedDate = jfd;
                    break calculateFixedDate;
                } else if (year == gregorianCutoverYear) {
                    fixedDate = gfd;
                    break calculateFixedDate;
                }
            }

            if (gfd >= gregorianCutoverDate) {
                if (jfd >= gregorianCutoverDate) {
                    fixedDate = gfd;
                } else {
                    // The date is in an "overlapping" period. No way
                    // to disambiguate it. Determine it using the
                    // previous date calculation.
                    if (calsys == gcal || calsys == null) {
                        fixedDate = gfd;
                    } else {
                        fixedDate = jfd;
                    }
                }
            } else {
                if (jfd < gregorianCutoverDate) {
                    fixedDate = jfd;
                } else {
                    // The date is in a "missing" period.
                    if (!isLenient()) {
                        throw new IllegalArgumentException("the specified date doesn't exist");
                    }
                    // Take the Julian date for compatibility, which
                    // will produce a Gregorian date.
                    fixedDate = jfd;
                }
            }
        }

        // millis represents local wall-clock time in milliseconds.
        long millis = (fixedDate - EPOCH_OFFSET) * ONE_DAY + timeOfDay;

        // Compute the time zone offset and DST offset.  There are two potential
        // ambiguities here.  We'll assume a 2:00 am (wall time) switchover time
        // for discussion purposes here.
        // 1. The transition into DST.  Here, a designated time of 2:00 am - 2:59 am
        //    can be in standard or in DST depending.  However, 2:00 am is an invalid
        //    representation (the representation jumps from 1:59:59 am Std to 3:00:00 am DST).
        //    We assume standard time.
        // 2. The transition out of DST.  Here, a designated time of 1:00 am - 1:59 am
        //    can be in standard or DST.  Both are valid representations (the rep
        //    jumps from 1:59:59 DST to 1:00:00 Std).
        //    Again, we assume standard time.
        // We use the TimeZone object, unless the user has explicitly set the ZONE_OFFSET
        // or DST_OFFSET fields; then we use those fields.
        TimeZone zone = getZone();
        // BEGIN Android-changed: time zone related calculation via helper methods
        int tzMask = fieldMask & (ZONE_OFFSET_MASK|DST_OFFSET_MASK);

        millis = adjustForZoneAndDaylightSavingsTime(tzMask, millis, zone);
        // END Android-changed: time zone related calculation via helper methods

        // Set this calendar's time in milliseconds
        time = millis;

        int mask = computeFields(fieldMask | getSetStateFields(), tzMask);

        if (!isLenient()) {
            for (int field = 0; field < FIELD_COUNT; field++) {
                if (!isExternallySet(field)) {
                    continue;
                }
                if (originalFields[field] != internalGet(field)) {
                    String s = originalFields[field] + " -> " + internalGet(field);
                    // Restore the original field values
                    System.arraycopy(originalFields, 0, fields, 0, fields.length);
                    throw new IllegalArgumentException(getFieldName(field) + ": " + s);
                }
            }
        }
        setFieldsNormalized(mask);
    }
393969
public Calendar getSelectedTime() {
        final Object selectedItem = getSelectedItem();
        if(!(selectedItem instanceof TimeItem))
            return null;
        return ((TimeItem) selectedItem).getTime();
    }
1245391
@SuppressWarnings("WeakerAccess")
    public int findBeatAtTime(long milliseconds) {
        int found = Arrays.binarySearch(timeWithinTrackValues, milliseconds);
        if (found >= 0) {  // An exact match, just change 0-based array index to 1-based beat number
            return found + 1;
        } else if (found == -1) {  // We are before the first beat
            return found;
        } else {  // We are after some beat, report its beat number
            return -(found + 1);
        }
    }