本文整理汇总了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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例10: hasExpired
import java.util.Date; //导入方法依赖的package包/类
public boolean hasExpired()
{
if( expires == null )
{
return false;
}
Date now = new Date();
return now.after(expires);
}
示例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 "";
}
示例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();
}
示例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;
}
示例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());
}
}
示例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));
}
}