java.util.Calendar.compareTo()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(232)

本文整理了Java中java.util.Calendar.compareTo()方法的一些代码示例,展示了Calendar.compareTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Calendar.compareTo()方法的具体详情如下:
包路径:java.util.Calendar
类名称:Calendar
方法名:compareTo

Calendar.compareTo介绍

[英]Compares the time represented by this Calendar to that represented by the given Calendar.
[中]将此日历表示的时间与给定日历表示的时间进行比较。

代码示例

代码示例来源:origin: jphp-group/jphp

@Override
public boolean __smaller(WrapTime iObject) {
  return calendar.compareTo(iObject.calendar) < 0;
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean __equal(WrapTime iObject) {
  return calendar.compareTo(iObject.calendar) == 0;
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean __greater(WrapTime iObject) {
  return calendar.compareTo(iObject.calendar) > 0;
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean __greaterEq(WrapTime iObject) {
  return calendar.compareTo(iObject.calendar) >= 0;
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean __smallerEq(WrapTime iObject) {
  return calendar.compareTo(iObject.calendar) <= 0;
}

代码示例来源:origin: stackoverflow.com

Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.compareTo(c2);

代码示例来源:origin: jphp-group/jphp

@Override
public boolean __identical(WrapTime iObject) {
  return calendar.compareTo(iObject.calendar) == 0 && timeZone.getID().equals(iObject.timeZone.getID());
}

代码示例来源:origin: EngineHub/WorldEdit

@Override
public int compareTo(Snapshot o) {
  if (o.date == null || date == null) {
    // Remove the folder from the name
    int i = name.indexOf('/'), j = o.name.indexOf('/');
    return name.substring((i > 0 ? 0 : i)).compareTo(o.name.substring((j > 0 ? 0 : j)));
  } else {
    return date.compareTo(o.date);
  }
}

代码示例来源:origin: cachecats/coderiver

/**
 * 时间比较(如果myDate>compareDate返回1,<返回-1,相等返回0)
 *
 * @param myDate      时间
 * @param compareDate 要比较的时间
 * @return int
 */
public static int dateCompare(Date myDate, Date compareDate) {
  Calendar myCal = Calendar.getInstance();
  Calendar compareCal = Calendar.getInstance();
  myCal.setTime(myDate);
  compareCal.setTime(compareDate);
  return myCal.compareTo(compareCal);
}

代码示例来源:origin: org.codehaus.groovy/groovy

@Deprecated
public static void upto(Calendar self, Calendar to, Closure closure) {
  if (self.compareTo(to) <= 0) {
    for (Calendar i = (Calendar) self.clone(); i.compareTo(to) <= 0; i = next(i)) {
      closure.call(i);
    }
  } else
    throw new GroovyRuntimeException("The argument (" + to +
        ") to upto() cannot be earlier than the value (" + self + ") it's called on.");
}

代码示例来源:origin: org.codehaus.groovy/groovy

@Deprecated
  public static void downto(Calendar self, Calendar to, Closure closure) {
    if (self.compareTo(to) >= 0) {
      for (Calendar i = (Calendar) self.clone(); i.compareTo(to) >= 0; i = previous(i)) {
        closure.call(i);
      }
    } else
      throw new GroovyRuntimeException("The argument (" + to +
          ") to downto() cannot be later than the value (" + self + ") it's called on.");
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Determines how two calendars compare up to no more than the specified
 * most significant field.
 *
 * @param cal1 the first calendar, not <code>null</code>
 * @param cal2 the second calendar, not <code>null</code>
 * @param field the field from {@code Calendar}
 * @return a negative integer, zero, or a positive integer as the first
 * calendar is less than, equal to, or greater than the second.
 * @throws IllegalArgumentException if any argument is <code>null</code>
 * @see #truncate(Calendar, int)
 * @see #truncatedCompareTo(Date, Date, int)
 * @since 3.0
 */
public static int truncatedCompareTo(final Calendar cal1, final Calendar cal2, final int field) {
  final Calendar truncatedCal1 = truncate(cal1, field);
  final Calendar truncatedCal2 = truncate(cal2, field);
  return truncatedCal1.compareTo(truncatedCal2);
}

代码示例来源:origin: org.assertj/assertj-core

break;
if (calendarActual.compareTo(calendarOther) != 0)
 throw failures.failure(info, ShouldBeEqualWithTimePrecision.shouldBeEqual(actual, other, precision));

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

Calendar check = Calendar.getInstance();
check.add(Calendar.SECOND, -2 * new Long(cacheSeconds).intValue());
if (check.compareTo(last) < 0) {
  response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
  return;

代码示例来源:origin: joel-costigliola/assertj-core

break;
if (calendarActual.compareTo(calendarOther) != 0)
 throw failures.failure(info, ShouldBeEqualWithTimePrecision.shouldBeEqual(actual, other, precision));

代码示例来源:origin: stackoverflow.com

calSet.set(Calendar.MILLISECOND, 0);
if (calSet.compareTo(calNow) <= 0) {

代码示例来源:origin: jphp-group/jphp

@Signature(@Arg(value = "time", nativeType = WrapTime.class))
public Memory compare(Environment env, Memory... args) {
  return LongMemory.valueOf(calendar.compareTo(args[0].toObject(WrapTime.class).calendar));
}

代码示例来源:origin: jenkinsci/jenkins

WaitingItem top = peek();
if (top.timestamp.compareTo(new GregorianCalendar()) > 0) {
  LOGGER.log(Level.FINEST, "Finished moving all ready items from queue.");
  break; // finished moving all ready items from queue

代码示例来源:origin: jenkinsci/jenkins

OUTER:
while (true) {
  if (cal.compareTo(twoYearsFuture) > 0) {

代码示例来源:origin: jenkinsci/jenkins

if (cal.compareTo(twoYearsAgo) < 0) {

相关文章