当前位置: 首页>>代码示例>>Java>>正文


Java Date.compareTo方法代码示例

本文整理汇总了Java中java.util.Date.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java Date.compareTo方法的具体用法?Java Date.compareTo怎么用?Java Date.compareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Date的用法示例。


在下文中一共展示了Date.compareTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkFecha

import java.util.Date; //导入方法依赖的package包/类
@Check
public void checkFecha(final Restaurante restaurante) {
  try {
    SimpleDateFormat formateadorFecha = new SimpleDateFormat("dd-MM-yyyy");
    Date fechaDada = formateadorFecha.parse(restaurante.getFecha());
    Calendar fechaActual = Calendar.getInstance();
    Date _time = fechaActual.getTime();
    boolean _greaterThan = (fechaDada.compareTo(_time) > 0);
    if (_greaterThan) {
      this.error("La fecha tiene que ser igual o menor que la actual", 
        RestaurantePackage.Literals.RESTAURANTE__FECHA, RestauranteValidator.FECHA_INVALIDA);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:vicegd,项目名称:org.xtext.dsl.restaurante,代码行数:17,代码来源:RestauranteValidator.java

示例2: compareDatesString

import java.util.Date; //导入方法依赖的package包/类
public static int compareDatesString(String dateString, String anotherDateString, SimpleDateFormat simpleDateFormat) {
    final Date date;
    final Date anotherDate;
    try {
        date = simpleDateFormat.parse(dateString);
        anotherDate = simpleDateFormat.parse(anotherDateString);
    } catch (ParseException e) {
        throw new AssertionError("Incorrect date format" + e);
    }
    return date.compareTo(anotherDate);
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:12,代码来源:DateUtils.java

示例3: getModifiedAnnotation

import java.util.Date; //导入方法依赖的package包/类
@Override
public String getModifiedAnnotation() {
	if (userPermissionProfilesOut != null && userPermissionProfilesOut.size() > 0) {
		Long version = null;
		UserOutVO modifiedUser = null;
		Date modifiedTimestamp = null;
		Iterator<UserPermissionProfileOutVO> it = userPermissionProfilesOut.iterator();
		while (it.hasNext()) {
			UserPermissionProfileOutVO userPermissionProfilesOutVO = it.next();
			Date tagValueModifiedTimestamp = userPermissionProfilesOutVO.getModifiedTimestamp();
			if (modifiedTimestamp == null || (tagValueModifiedTimestamp != null && modifiedTimestamp.compareTo(tagValueModifiedTimestamp) < 0)) {
				modifiedUser = userPermissionProfilesOutVO.getModifiedUser();
				modifiedTimestamp = tagValueModifiedTimestamp;
			}
			if (version == null) {
				version = userPermissionProfilesOutVO.getVersion();
			} else {
				version = Math.max(version.longValue(), userPermissionProfilesOutVO.getVersion());
			}
		}
		if (version == null || modifiedUser == null || modifiedTimestamp == null) {
			return super.getModifiedAnnotation();
		} else {
			return WebUtil.getModifiedAnnotation(version.longValue(), modifiedUser, modifiedTimestamp);
		}
	} else {
		return super.getModifiedAnnotation();
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:30,代码来源:UserPermissionProfileBean.java

示例4: getRangeInMinutesForDay

import java.util.Date; //导入方法依赖的package包/类
/**
 * Get the amount of minutes for the event on a specific day. This is useful
 * if the event spans several days.
 *
 * @param targetDay
 *            The date to check
 * @return the amount of minutes for the event on a specific day. This is useful
 * if the event spans several days.
 */
public long getRangeInMinutesForDay(Date targetDay) {

    long rangeInMinutesForDay;

    // we must take into account that here can be not only 1 and 2 days, but
    // 1, 2, 3, 4... days first and last days - special cases all another
    // days between first and last - have range "ALL DAY"
    if (isTimeOnDifferentDays()) {
        if (targetDay.compareTo(getStart()) == 0) { // for first day
            rangeInMinutesForDay = DateConstants.DAYINMINUTES
                    - (getStartTime().getTime() - getStart().getTime())
                    / DateConstants.MINUTEINMILLIS;

        } else if (targetDay.compareTo(getEnd()) == 0) { // for last day
            rangeInMinutesForDay = (getEndTime().getTime()
                    - getEnd().getTime())
                    / DateConstants.MINUTEINMILLIS;

        } else { // for in-between days
            rangeInMinutesForDay = DateConstants.DAYINMINUTES;
        }
    } else { // simple case - period is in one day
        rangeInMinutesForDay = getRangeInMinutes();
    }
    return rangeInMinutesForDay;
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:36,代码来源:CalendarItem.java

示例5: compare

import java.util.Date; //导入方法依赖的package包/类
@Override
public int compare ( final ChangeEntry o1, final ChangeEntry o2 )
{
    final Date d1 = o1.getDate ();
    final Date d2 = o2.getDate ();
    if ( !this.invert )
    {
        return d1.compareTo ( d2 );
    }
    else
    {
        return -d1.compareTo ( d2 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:15,代码来源:ChangeEntryComparator.java

示例6: getExpired

import java.util.Date; //导入方法依赖的package包/类
private static Boolean getExpired(Date today, Date expiration) {
	if (today != null && expiration != null) {
		if (today.compareTo(expiration) > 0) {
			return true;
		} else {
			return false;
		}
	}
	return null;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:11,代码来源:WebUtil.java

示例7: compareDates

import java.util.Date; //导入方法依赖的package包/类
public static int compareDates(Object o1, Object o2) {
    Date d1 = DataUtil.parseDate(String.valueOf(o1));
    Date d2 = DataUtil.parseDate(String.valueOf(o2));
    if (d1 == null && d2 == null) {
        return 0;
    } else if (d1 == null) {
        return 1;
    } else if (d2 == null) {
        return -1;
    } else {
        return d2.compareTo(d1);
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:aem-epic-tool,代码行数:14,代码来源:DataUtil.java

示例8: Transactions

import java.util.Date; //导入方法依赖的package包/类
public Transactions(
        File inputJsonFile, Date minimumDate, Date maximumDate) throws IOException {
    JSONArray jsonArray = new JSONArray(
            FileUtils.readFileToString(inputJsonFile, StandardCharsets.UTF_8));

    for (int i = 0; i < jsonArray.length(); i++) {
        Transaction transaction = new Transaction(jsonArray.getJSONObject(i));
        final Date saleDate = transaction.getSaleDate();
        if (saleDate.compareTo(minimumDate) >= 0 && saleDate.compareTo(maximumDate) <= 0)
            transactions.add(transaction);
    }
}
 
开发者ID:BigBrassBand,项目名称:remittanceparse,代码行数:13,代码来源:Transactions.java

示例9: isEventExpired

import java.util.Date; //导入方法依赖的package包/类
public boolean isEventExpired(){
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);

    Date date = c.getTime();
    return date.compareTo(eventDeadline) > 0;
}
 
开发者ID:wendyltan,项目名称:EasyTodo,代码行数:11,代码来源:TodoEvent.java

示例10: getTodayFirstPosition

import java.util.Date; //导入方法依赖的package包/类
/**
 * 获取当天提醒第一条记录索引
 **/
@Override
public int getTodayFirstPosition() {
    for (int i = 0; i < showDatas.size(); i++) {
        Date rdate = showDatas.get(i).t.getRdate();
        if (rdate.compareTo(TimeUtils.getTodayDate()) >= 0
                && rdate.before(TimeUtils.getTomorrow())) {
            return i + 1;
        }
    }
    return -1;
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:15,代码来源:RemindPresenter.java

示例11: compare

import java.util.Date; //导入方法依赖的package包/类
@Override
public int compare(CvPositionPDFVO a, CvPositionPDFVO b) {
	if (a != null && b != null) {
		CvSectionVO cvSectionA = a.getSection();
		CvSectionVO cvSectionB = b.getSection();
		if (cvSectionA != null && cvSectionB != null) {
			if (cvSectionA.getPosition() < cvSectionB.getPosition()) {
				return -1;
			} else if (cvSectionA.getPosition() > cvSectionB.getPosition()) {
				return 1;
			} else {
				Date dateA = (a.getStart() != null ? a.getStart() : a.getStop());
				Date dateB = (b.getStart() != null ? b.getStart() : b.getStop());
				if (dateA != null && dateB != null) {
					return dateA.compareTo(dateB);
				} else if (dateA == null && dateB != null) {
					return -1;
				} else if (dateA != null && dateB == null) {
					return 1;
				} else {
					return 0;
				}
			}
		} else if (cvSectionA == null && cvSectionB != null) {
			return -1;
		} else if (cvSectionA != null && cvSectionB == null) {
			return 1;
		} else {
			return 0;
		}
	} else if (a == null && b != null) {
		return -1;
	} else if (a != null && b == null) {
		return 1;
	} else {
		return 0;
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:39,代码来源:CvPositionPDFVOComparator.java

示例12: getWeek

import java.util.Date; //导入方法依赖的package包/类
protected int getWeek(Date date) {
    for (int idx=0;idx+1<iWeekDate.size();idx++)
        if (date.compareTo(iWeekDate.elementAt(idx))<0) return idx;
    return iWeekDate.size()-1;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:6,代码来源:MakeAssignmentsForClassEvents.java

示例13: findPosition

import java.util.Date; //导入方法依赖的package包/类
private long findPosition(File file, Date date) throws IOException {
	RandomAccessFile raf = new RandomAccessFile(file, "r");
	
	try {
		Date cur_date = extractDate(raf);
		if (cur_date != null) {
			int compare = date.compareTo(cur_date);
			if (compare > 0) {
				date.setTime(date.getTime() - 1);
				long min = raf.getFilePointer();
				long max = raf.length();
				Date last_date = null;
				long last_pos = 0;
				while (cur_date != null && !cur_date.equals(last_date) && !cur_date.equals(date)) {
					last_date = cur_date;
					last_pos = raf.getFilePointer();
					long cur = min + ((max - min) / 2);
					raf.seek(cur);
					cur_date = extractDate(raf);
					if (cur_date == null || date.compareTo(cur_date) < 0) {
						max = cur;
					} else {
						min = cur;
					}
				}
				date.setTime(date.getTime() + 1);
				
				if (cur_date != null && date.compareTo(cur_date) < 0) {
					raf.seek(min);
					cur_date = extractDate(raf);
				}
				
				// Fix #1788 : 'Out of range Date' exception when start date is 2011-01-25 12:32 for log file of #1787
				// can find next cur_date but last_date is a valid candidate for the end date
				if (cur_date == null && last_date != null) {
					cur_date = last_date;
					raf.seek(last_pos);
				}
				while (cur_date != null && date.compareTo(cur_date) > 0) {
					raf.skipBytes(1);
					cur_date = extractDate(raf);
				}
			}
			if (cur_date != null) {
				return raf.getFilePointer();
			}
		}
		throw new IOException("Out of range Date");
	} finally {
		raf.close();
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:53,代码来源:TemporalInputStream.java

示例14: future

import java.util.Date; //导入方法依赖的package包/类
/** 未来某一天 */
public static void future(Date date, String key) {
	if (date != null && date.compareTo(new Date()) <= 0) {
		throw new IllegalArgumentException(getMessage(key + "_NOT_FUTURE"));
	}
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:7,代码来源:Assert.java

示例15: isGreaterEqual

import java.util.Date; //导入方法依赖的package包/类
/** Returns true if the date d1 is greater than date d1 or both are equal */
public static boolean isGreaterEqual(Date d1, Date d2) {
	return isEqual(d1, d2) || d1 != null && d1.compareTo(d2) > 0;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:5,代码来源:Tools.java


注:本文中的java.util.Date.compareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。