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


Java Date.after方法代码示例

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


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

示例1: countDutyday

import java.util.Date; //导入方法依赖的package包/类
/**
 * 计算两个Date之间的工作日时间差
 *
 * @param start 开始时间
 * @param end   结束时间
 * @return int 返回两天之间的工作日时间
 */
public static int countDutyday(Date start, Date end) {
    if (start == null || end == null) return 0;
    if (start.after(end)) return 0;
    Calendar c_start = Calendar.getInstance();
    Calendar c_end = Calendar.getInstance();
    c_start.setTime(start);
    c_end.setTime(end);
    //时分秒毫秒清零
    c_start.set(Calendar.HOUR_OF_DAY, 0);
    c_start.set(Calendar.MINUTE, 0);
    c_start.set(Calendar.SECOND, 0);
    c_start.set(Calendar.MILLISECOND, 0);
    c_end.set(Calendar.HOUR_OF_DAY, 0);
    c_end.set(Calendar.MINUTE, 0);
    c_end.set(Calendar.SECOND, 0);
    c_end.set(Calendar.MILLISECOND, 0);
    //初始化第二个日期,这里的天数可以随便的设置
    int dutyDay = 0;
    while (c_start.compareTo(c_end) < 0) {
        if (c_start.get(Calendar.DAY_OF_WEEK) != 1 && c_start.get(Calendar.DAY_OF_WEEK) != 7)
            dutyDay++;
        c_start.add(Calendar.DAY_OF_YEAR, 1);
    }
    return dutyDay;
}
 
开发者ID:luotuo,项目名称:springboot-security-wechat,代码行数:33,代码来源:DateUtils.java

示例2: getPreviousTransition

import java.util.Date; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * @stable ICU 3.8
 */
@Override
public TimeZoneTransition getPreviousTransition(long base, boolean inclusive) {
    if (!useDaylight) {
        return null;
    }

    initTransitionRules();
    long firstTransitionTime = firstTransition.getTime();
    if (base < firstTransitionTime || (!inclusive && base == firstTransitionTime)) {
        return null;
    }
    Date stdDate = stdRule.getPreviousStart(base, dstRule.getRawOffset(),
                                            dstRule.getDSTSavings(), inclusive);
    Date dstDate = dstRule.getPreviousStart(base, stdRule.getRawOffset(),
                                            stdRule.getDSTSavings(), inclusive);
    if (stdDate != null && (dstDate == null || stdDate.after(dstDate))) {
        return new TimeZoneTransition(stdDate.getTime(), dstRule, stdRule);
    }
    if (dstDate != null && (stdDate == null || dstDate.after(stdDate))) {
        return new TimeZoneTransition(dstDate.getTime(), stdRule, dstRule);
    }
    return null;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:28,代码来源:SimpleTimeZone.java

示例3: updateDateValidated

import java.util.Date; //导入方法依赖的package包/类
/**
 * Update a html input text value with a date.
 *
 * @param pageElement
 *            Is target element
 * @param dateType
 *            "any", "future", "today", "future_strict"
 * @param date
 *            Is the new data (date)
 * @throws TechnicalException
 *             is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
 *             Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_WRONG_DATE_FORMAT} message (no screenshot, no exception) or with
 *             {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNEXPECTED_DATE} message
 *             (with screenshot, no exception)
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
protected void updateDateValidated(PageElement pageElement, String dateType, String date) throws TechnicalException, FailureException {
    logger.debug("updateDateValidated with elementName={}, dateType={} and date={}", pageElement, dateType, date);
    DateFormat formatter = new SimpleDateFormat(Constants.DATE_FORMAT);
    Date today = Calendar.getInstance().getTime();
    try {
        Date valideDate = formatter.parse(date);
        if ("any".equals(dateType)) {
            logger.debug("update Date with any date: {}", date);
            updateText(pageElement, date);
        } else if (formatter.format(today).equals(date) && ("future".equals(dateType) || "today".equals(dateType))) {
            logger.debug("update Date with today");
            updateText(pageElement, date);
        } else if (valideDate.after(Calendar.getInstance().getTime()) && ("future".equals(dateType) || "future_strict".equals(dateType))) {
            logger.debug("update Date with a date after today: {}", date);
            updateText(pageElement, date);
        } else {
            new Result.Failure<>(date, Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_UNEXPECTED_DATE), Messages.getMessage(Messages.DATE_GREATER_THAN_TODAY)), true,
                    pageElement.getPage().getCallBack());
        }
    } catch (ParseException e) {
        new Result.Failure<>(e.getMessage(), Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_WRONG_DATE_FORMAT), pageElement, date), false, pageElement.getPage().getCallBack());
    }

}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:42,代码来源:Step.java

示例4: Zeitraum

import java.util.Date; //导入方法依赖的package包/类
/**
 * Erstellt einen neuen Zeitraum.
 *
 * @param von Datum von wann an der Zeitraum gilt (inklusive), ohne Zeitinformation
 * @param bis Datum bis wann der Zeitraum gilt (inklusive), ohne Zeitinformation
 */
public Zeitraum(Date von, Date bis) {
	if (von == null) {
		throw new IllegalArgumentException("von ist null");
	}
	if (bis == null) {
		throw new IllegalArgumentException("bis ist null");
	}
	if (von.after(bis)) {
		throw new IllegalArgumentException("von (" + von + ") muss gleich oder vor bis (" + bis
			+ ") sein!");
	}
	this.von = von;
	this.bis = bis;
}
 
开发者ID:dvbern,项目名称:date-helper,代码行数:21,代码来源:Zeitraum.java

示例5: isMostRecentlyUsed

import java.util.Date; //导入方法依赖的package包/类
private boolean isMostRecentlyUsed(Collection<DaemonInfo> daemonInfos, DaemonContext thisDaemonContext) {
    String mruUid = null;
    Date mruTimestamp = new Date(Long.MIN_VALUE);
    for (DaemonInfo daemonInfo : daemonInfos) {
        Date daemonAccessTime = daemonInfo.getLastBusy();
        if (daemonAccessTime.after(mruTimestamp)) {
            mruUid = daemonInfo.getUid();
            mruTimestamp = daemonAccessTime;
        }
    }
    return thisDaemonContext.getUid().equals(mruUid);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:NotMostRecentlyUsedDaemonExpirationStrategy.java

示例6: authenticateLoginRequest

import java.util.Date; //导入方法依赖的package包/类
/**
    * Checks hash for LoginRequest calls. Differs from the method above in a way that datetime is expected to contain
    * real value and it must be quite recent one.
    *
    * @param map
    * @param datetime
    * @param username
    * @param method
    * @param lsid
    *            this parameter provided only if coming from learnerStrictAuth
    * @param hashValue
    * @throws AuthenticationException
    */
   public static void authenticateLoginRequest(ExtServer map, String datetime, String username, String method,
    String lsid, String hashValue) throws AuthenticationException {

if (map == null) {
    throw new AuthenticationException("The third party server is not configured on LAMS server");
}
if (map.getDisabled()) {
    throw new AuthenticationException("The third party server is disabled");
}

// check if there is datetime check and if so if it isn't too old
if (map.getTimeToLiveLoginRequestEnabled()) {
    long datetimeParam;
    try {
	datetimeParam = Long.parseLong(datetime);
    } catch (NumberFormatException e) {
	throw new AuthenticationException(
		"The third party server provided wrong format of datetime, datetime = " + datetime, e);
    }

    int timeToLiveLoginRequest = map.getTimeToLiveLoginRequest();
    // sum up request time and maximum allowed request's time to live
    Date requestTimePlusTimeToLive = new Date(datetimeParam + timeToLiveLoginRequest * 60 * 1000);
    Date requestTimeMinusTimeToLive = new Date(datetimeParam - timeToLiveLoginRequest * 60 * 1000);
    Date now = new Date();
    if (requestTimePlusTimeToLive.before(now) || requestTimeMinusTimeToLive.after(now)) {
	throw new AuthenticationException("Request is not in the time range of " + timeToLiveLoginRequest
		+ " minutes. Please, contact sysadmin.");
    }
}

//learnerStrictAuth hash [ts + uid + method + lsid + serverID + serverKey]
//otherwise [ts + uid + method + serverID + serverKey]
String plaintext = datetime.toLowerCase().trim() + username.toLowerCase().trim() + method.toLowerCase().trim()
	+ ("learnerStrictAuth".equals(method) ? lsid.toLowerCase().trim() : "")
	+ map.getServerid().toLowerCase().trim() + map.getServerkey().toLowerCase().trim();
Authenticator.checkHash(plaintext, hashValue);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:Authenticator.java

示例7: main

import java.util.Date; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    for (int i = 0; i < 1000; i++) {
        Date d = new Date();
        Timestamp ts = new Timestamp(d.getTime());
        if (d.after(ts)) {
            throw new RuntimeException("date with time " + d.getTime()
                    + " should not be after TimeStamp , Nanos component of "
                            + "TimeStamp is " +ts.getNanos());
        }
        Thread.sleep(1);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:Bug8135055.java

示例8: a

import java.util.Date; //导入方法依赖的package包/类
public static int a(Date date, Date date2) {
    if (!date.after(date2)) {
        Date date3 = date2;
        date2 = date;
        date = date3;
    }
    return (int) ((date.getTime() - date2.getTime()) / 1000);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:bt.java

示例9: a

import java.util.Date; //导入方法依赖的package包/类
a a(Date date, Date date2) {
    if (date.after(date2)) {
        this.c = this.a.format(date2);
        this.d = this.a.format(date);
    } else {
        this.c = this.a.format(date);
        this.d = this.a.format(date2);
    }
    return this;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:a.java

示例10: hasExpired

import java.util.Date; //导入方法依赖的package包/类
public boolean hasExpired()
{
	if( expires == null )
	{
		return false;
	}
	Date now = new Date();
	return now.after(expires);
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:HttpServiceImpl.java

示例11: validateCrear

import java.util.Date; //导入方法依赖的package包/类
public String validateCrear(final String polizaNumero, final Persona polizaCliente, final Compania polizaCompania,
		final Date polizaFechaEmision, final Date polizaFechaVigencia, final Date polizaFechaVencimiento,
		final TipoPago polizaTipoDePago, final DetalleTipoPago polizaPago, final double polizaImporteTotal,
		final float riesgoIntegralComercioRobo, final float riesgoIntegralComercioCristales,
		final float riesgoIntegralComercioIncendioEdificio, final float riesgoIntegralComercioIncendioContenido,
		final float riesgoIntegralComercioRc, final float riesgoIntegralComercioRcl,
		final float riesgoIntegralComercioDanioPorAgua, final float riesgoIntegralComercioRCC,
		final String riesgoIntegralComercioOtrosNombre, final double riesgoIntegralComercioOtrosMonto) {
	if (polizaFechaVigencia.after(polizaFechaVencimiento)) {
		return "La fecha de vigencia es mayor a la de vencimiento";
	}
	return "";
}
 
开发者ID:leandrogonqn,项目名称:Proyecto2017Seguros,代码行数:14,代码来源:PolizaIntegralComercioMenu.java

示例12: init

import java.util.Date; //导入方法依赖的package包/类
public static void init() {
    cancelAll();
    //changeDateTimer.cancel();
    Vector events = (Vector)EventsManager.getActiveEvents();
    _timers = new Vector();
    /*DEBUG*/System.out.println("----------");
    for (int i = 0; i < events.size(); i++) {
        Event ev = (Event)events.get(i);
        Date evTime = ev.getTime();
    /*DEBUG*/System.out.println((Calendar.getInstance()).getTime());
      //  if (evTime.after(new Date())) {
   if (evTime.after((Calendar.getInstance()).getTime())) {	
            EventTimer t = new EventTimer(ev);
            t.schedule(new NotifyTask(t), ev.getTime());                
            _timers.add(t);
            /*DEBUG*/System.out.println(ev.getTimeString());
        }
    }
    /*DEBUG*/System.out.println("----------");
    Date midnight = getMidnight();
    changeDateTimer.schedule(new TimerTask() {
            public void run() {
                init();
                this.cancel();
            }
    }, midnight);
    notifyChanged();
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:29,代码来源:EventsScheduler.java

示例13: max

import java.util.Date; //导入方法依赖的package包/类
/**
 * Returns the maximum of two dates. A null date is treated as being less
 * than any non-null date.
 */
public static Date max(Date d1, Date d2) {
    if (d1 == null && d2 == null) return null;
    if (d1 == null) return d2;
    if (d2 == null) return d1;
    return (d1.after(d2)) ? d1 : d2;
}
 
开发者ID:zom,项目名称:zombot-java,代码行数:11,代码来源:DateUtils.java

示例14: reconcileFlow

import java.util.Date; //导入方法依赖的package包/类
/**
 * Add to-be-reconciled flow to the queue.
 *
 * @param ofmRcIn the ofm rc in
 */
@Override
public void reconcileFlow(OFMatchReconcile ofmRcIn, EventPriority priority) {
	if (ofmRcIn == null) return;

	// Make a copy before putting on the queue.
	OFMatchReconcile myOfmRc = new OFMatchReconcile(ofmRcIn);

	flowQueue.offer(myOfmRc, priority);
	ctrFlowReconcileRequest.increment();

	Date currTime = new Date();
	long delay = 0;

	/** schedule reconcile task immidiately if it has been more than 1 sec
	 *  since the last run. Otherwise, schedule the reconcile task in
	 *  DELAY_MILLISEC.
	 */
	if (currTime.after(new Date(lastReconcileTime.getTime() + 1000))) {
		delay = 0;
	} else {
		delay = FLOW_RECONCILE_DELAY_MILLISEC;
	}
	flowReconcileTask.reschedule(delay, TimeUnit.MILLISECONDS);

	if (logger.isTraceEnabled()) {
		logger.trace("Reconciling flow: {}, total: {}",
				myOfmRc.toString(), flowQueue.size());
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:35,代码来源:FlowReconcileManager.java

示例15: assertDateIsFuture

import java.util.Date; //导入方法依赖的package包/类
private static void assertDateIsFuture(Date date, long leeway, Date today) {
    today.setTime(today.getTime() - leeway * 1000);
    if (date != null && today.after(date)) {
        throw new TokenExpiredException(String.format("The Token has expired on %s.", date));
    }
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:7,代码来源:VerificationAndAssertion.java


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