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

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

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

Calendar.equals介绍

[英]Compares the given object to this Calendar and returns whether they are equal. The object must be an instance of Calendar and have the same properties.
[中]将给定对象与此日历进行比较,并返回它们是否相等。该对象必须是日历实例,并且具有相同的属性。

代码示例

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

/**
 * Returns true if {@code object} is a GregorianCalendar with the same
 * properties.
 */
@Override public boolean equals(Object object) {
  if (!(object instanceof GregorianCalendar)) {
    return false;
  }
  if (object == this) {
    return true;
  }
  return super.equals(object)
      && gregorianCutover == ((GregorianCalendar) object).gregorianCutover;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * Return the next calendar in the iteration
 *
 * @return Object calendar for the next date
 */
public Object next() {
  if (spot.equals(endFinal)) {
    throw new NoSuchElementException();
  }
  spot.add(Calendar.DATE, 1);
  return spot.clone();
}

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

/**
 * Return the next calendar in the iteration
 *
 * @return Object calendar for the next date
 */
@Override
public Calendar next() {
  if (spot.equals(endFinal)) {
    throw new NoSuchElementException();
  }
  spot.add(Calendar.DATE, 1);
  return (Calendar) spot.clone();
}

代码示例来源:origin: openhab/openhab1-addons

@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (obj == null) {
    return false;
  }
  if (getClass() != obj.getClass()) {
    return false;
  }
  DateTimeType other = (DateTimeType) obj;
  if (calendar == null) {
    if (other.calendar != null) {
      return false;
    }
  } else if (!calendar.equals(other.calendar)) {
    return false;
  }
  return true;
}

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

Calendar cal1 = Calendar.getInstance();
     Calendar cal2 = Calendar.getInstance();
     cal1.setTime(date1);
     cal2.setTime(date2);
     if(cal1.after(cal2)){
       System.out.println("Date1 is after Date2");
     }
     if(cal1.before(cal2)){
       System.out.println("Date1 is before Date2");
     }
     if(cal1.equals(cal2)){
       System.out.println("Date1 is equal Date2");
     }

代码示例来源:origin: org.postgresql/postgresql

@Override
public boolean equals(Object obj) {
 if (this == obj) {
  return true;
 }
 if (!super.equals(obj)) {
  return false;
 }
 if (!(obj instanceof PGTime)) {
  return false;
 }
 PGTime other = (PGTime) obj;
 if (calendar == null) {
  if (other.calendar != null) {
   return false;
  }
 } else if (!calendar.equals(other.calendar)) {
  return false;
 }
 return true;
}

代码示例来源:origin: org.postgresql/postgresql

@Override
public boolean equals(Object obj) {
 if (this == obj) {
  return true;
 }
 if (!super.equals(obj)) {
  return false;
 }
 if (!(obj instanceof PGTimestamp)) {
  return false;
 }
 PGTimestamp other = (PGTimestamp) obj;
 if (calendar == null) {
  if (other.calendar != null) {
   return false;
  }
 } else if (!calendar.equals(other.calendar)) {
  return false;
 }
 return true;
}

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

if (tCal1.equals(calStatic)) // hide from unused variable detector;
if (System.currentTimeMillis() < 1L)
  return; // some other code in between
if (tCal2.equals(calStatic))
  return; // should fire

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

private Calendar getDateAfterRepeat(Calendar date) {
  Calendar current = TimeZoneUtil.convertToTimeZone(start,
                           date.getTimeZone());
  if (repeatWithNoBounds) {
    while (current.before(date) || current.equals(date)) { // As long as current date is not past the engine date, we keep looping
      Calendar newTime = add(current,
                  period);
      if (newTime.equals(current) || newTime.before(current)) {
        break;
      }
      current = newTime;
    }
  } else {
    int maxLoops = times;
    if (maxIterations > 0) {
      maxLoops = maxIterations - times;
    }
    for (int i = 0; i < maxLoops + 1 && !current.after(date); i++) {
      current = add(current,
             period);
    }
  }
  return current.before(date) ? date : TimeZoneUtil.convertToTimeZone(current,
                                    clockReader.getCurrentTimeZone());
}

代码示例来源:origin: org.apache.poi/poi

/**
   * {@inheritDoc}
   * <p>
   * For a date, this is <tt>"mm/d/y"</tt>.
   */
  public void simpleValue(StringBuffer toAppendTo, Object value) {
    synchronized (CellDateFormatter.class) {
      if (SIMPLE_DATE == null || !SIMPLE_DATE.EXCEL_EPOCH_CAL.equals(EXCEL_EPOCH_CAL)) {
        SIMPLE_DATE = new CellDateFormatter("mm/d/y");
      }
    }
    SIMPLE_DATE.formatValue(toAppendTo, value);
  }
}

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

now.set(Calendar.MILLISECOND, 0);
  check.set(Calendar.MILLISECOND, 0);
} while (!now.equals(check));
back = (Calendar) now.clone();
back.add(Calendar.HOUR, -2);
  now.set(Calendar.MILLISECOND, 0);
  check.set(Calendar.MILLISECOND, 0);
} while (!now.equals(check));
back = (Calendar) now.clone();
back.add(Calendar.MILLISECOND, millisInDay * -10);
  now.set(Calendar.MILLISECOND, 0);
  check.set(Calendar.MILLISECOND, 0);
} while (!now.equals(check));
back = (Calendar) now.clone();
back.add(Calendar.MILLISECOND, millisInDay * -2 * 7);

代码示例来源:origin: pentaho/mondrian

public Calendar nextOccurrence(Calendar after, boolean strict) {
    if (after == null) {
      return time;
    }
    if (time.after(after)) {
      return time;
    }
    if (!strict && time.equals(after)) {
      return time;
    }
    return null;
  }
}

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

assertFalse(fdf.format(lastTruncateCalendar) +" is not an extreme when truncating as Calendar with CalendarField-value "+ calendarField, truncatedCalendar.equals(DateUtils.truncate(nextTruncateCalendar, calendarField)));

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

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean eIsSet(int featureID) {
  switch (featureID) {
    case Csw20Package.REQUEST_STATUS_TYPE__TIMESTAMP:
      return TIMESTAMP_EDEFAULT == null ? timestamp != null : !TIMESTAMP_EDEFAULT.equals(timestamp);
  }
  return super.eIsSet(featureID);
}

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

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean eIsSet(int featureID) {
  switch (featureID) {
    case Csw20Package.ACKNOWLEDGEMENT_TYPE__ECHOED_REQUEST:
      return echoedRequest != null;
    case Csw20Package.ACKNOWLEDGEMENT_TYPE__REQUEST_ID:
      return REQUEST_ID_EDEFAULT == null ? requestId != null : !REQUEST_ID_EDEFAULT.equals(requestId);
    case Csw20Package.ACKNOWLEDGEMENT_TYPE__TIME_STAMP:
      return TIME_STAMP_EDEFAULT == null ? timeStamp != null : !TIME_STAMP_EDEFAULT.equals(timeStamp);
  }
  return super.eIsSet(featureID);
}

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

/**
 * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
 * @generated
 */
 public boolean eIsSet(int featureID) {
 switch (featureID) {
  case WfsPackage.FEATURE_COLLECTION_TYPE__LOCK_ID:
   return LOCK_ID_EDEFAULT == null ? lockId != null : !LOCK_ID_EDEFAULT.equals(lockId);
  case WfsPackage.FEATURE_COLLECTION_TYPE__TIME_STAMP:
   return TIME_STAMP_EDEFAULT == null ? timeStamp != null : !TIME_STAMP_EDEFAULT.equals(timeStamp);
  case WfsPackage.FEATURE_COLLECTION_TYPE__NUMBER_OF_FEATURES:
   return NUMBER_OF_FEATURES_EDEFAULT == null ? numberOfFeatures != null : !NUMBER_OF_FEATURES_EDEFAULT.equals(numberOfFeatures);
  case WfsPackage.FEATURE_COLLECTION_TYPE__FEATURE:
   return feature != null && !feature.isEmpty();
 }
 return super.eIsSet(featureID);
}

代码示例来源:origin: Impetus/Kundera

/**
 * 
 */
private void findAllQuery()
{
  EntityManager em = emf.createEntityManager();
  // Selet all query.
  String query = "Select s From StudentMongoCalendar s ";
  Query q = em.createQuery(query);
  List<StudentMongoCalendar> students = q.getResultList();
  Assert.assertNotNull(students);
  Assert.assertEquals(1, students.size());
  int count = 0;
  for (StudentMongoCalendar student : students)
  {
    if (student.getId().equals(((Calendar) getMaxValue(Calendar.class))))
    {
      Assert.assertEquals(getMaxValue(short.class), student.getAge());
      Assert.assertEquals("Kuldeep", student.getName());
      count++;
    }
  }
  Assert.assertEquals(1, count);
  em.close();
}

代码示例来源:origin: Impetus/Kundera

/**
 * 
 */
private void findAllQuery()
{
  EntityManager em = emf.createEntityManager();
  // Selet all query.
  String query = "Select s From StudentHBaseCalendar s ";
  Query q = em.createQuery(query);
  List<StudentHBaseCalendar> students = q.getResultList();
  Assert.assertNotNull(students);
  Assert.assertEquals(1, students.size());
  int count = 0;
  for (StudentHBaseCalendar student : students)
  {
    if (student.getId().equals(getMaxValue(Calendar.class)))
    {
      Assert.assertEquals(getMaxValue(short.class), student.getAge());
      Assert.assertEquals("Kuldeep", student.getName());
      count++;
    }
  }
  Assert.assertEquals(1, count);
  em.close();
}

代码示例来源:origin: Impetus/Kundera

/**
 * Find all query.
 */
private void findAllQuery()
{
  EntityManager em = emf.createEntityManager();
  // Selet all query.
  String query = "Select s From StudentHBaseCalendar s ";
  Query q = em.createQuery(query);
  List<StudentHBaseCalendar> students = q.getResultList();
  Assert.assertNotNull(students);
  Assert.assertEquals(1, students.size());
  int count = 0;
  for (StudentHBaseCalendar student : students)
  {
    if (student.getId().equals(getMaxValue(Calendar.class)))
    {
      Assert.assertEquals(getMaxValue(short.class), student.getAge());
      Assert.assertEquals("Kuldeep", student.getName());
      count++;
    }
  }
  Assert.assertEquals(1, count);
  em.close();
}

代码示例来源:origin: Impetus/Kundera

private void findByNameAndAgeGTEQAndLTEQ()
{
  EntityManager em;
  String query;
  Query q;
  List<StudentMongoCalendar> students;
  int count;
  em = emf.createEntityManager();
  query = "Select s From StudentMongoCalendar s where s.name = Kuldeep and s.age >= "
      + getPartialValue(short.class) + " and s.age <= " + getMaxValue(short.class);
  q = em.createQuery(query);
  students = q.getResultList();
  Assert.assertNotNull(students);
  Assert.assertEquals(1, students.size());
  count = 0;
  for (StudentMongoCalendar student : students)
  {
    if (student.getId().equals(getMaxValue(Calendar.class)))
    {
      Assert.assertEquals(getMaxValue(short.class), student.getAge());
      Assert.assertEquals("Kuldeep", student.getName());
      count++;
    }
  }
  Assert.assertEquals(1, count);
  em.close();
}

相关文章

微信公众号

最新文章

更多