java.sql.Timestamp.after()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(134)

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

Timestamp.after介绍

[英]Returns true if this timestamp object is later than the supplied timestamp, otherwise returns false.
[中]如果此时间戳对象晚于提供的时间戳,则返回true,否则返回false。

代码示例

代码示例来源:origin: cloudfoundry/uaa

public boolean isExpired() {
  if (getExpiresAt()==0) {
    return new Timestamp(System.currentTimeMillis()-getExpirationTime()).after(getCreated());
  } else {
    return getExpiresAt() < System.currentTimeMillis();
  }
}

代码示例来源:origin: apache/nifi

if (maxTimestampValue == null || colTimestampValue.after(maxTimestampValue)) {
  return colTimestampValue.toString();

代码示例来源:origin: hibernate/hibernate-orm

assertTrue( "Update timestamp should have changed due to update", theEntity.updated.after( updated ) );

代码示例来源:origin: zstackio/zstack

@Override
public boolean isTimeout() {
  Timestamp now = new Timestamp(new Date().getTime());
  return now.after(timeout);
}

代码示例来源:origin: zstackio/zstack

private void deleteExpiredCachedSessions() {
  Timestamp curr = getCurrentSqlDate();
  sessions.entrySet().removeIf(entry -> curr.after(entry.getValue().getExpiredDate()));
}

代码示例来源:origin: zstackio/zstack

private void handle(APIValidateSessionMsg msg) {
  APIValidateSessionReply reply = new APIValidateSessionReply();
  SessionInventory s = sessions.get(msg.getSessionUuid());
  Timestamp current = dbf.getCurrentSqlTime();
  boolean valid = true;
  if (s != null) {
    if (current.after(s.getExpiredDate())) {
      valid = false;
      logOutSession(s.getUuid());
    }
  } else {
    SessionVO session = dbf.findByUuid(msg.getSessionUuid(), SessionVO.class);
    if (session != null && current.after(session.getExpiredDate())) {
      valid = false;
      logOutSession(session.getUuid());
    } else if (session == null) {
      valid = false;
    }
  }
  reply.setValidSession(valid);
  bus.reply(msg, reply);
}

代码示例来源:origin: forcedotcom/phoenix

@Test
  public void testDemonstrateSetNanosOnTimestampLosingMillis() {
    Timestamp ts1 = new Timestamp(120055);
    ts1.setNanos(60);
    
    Timestamp ts2 = new Timestamp(120100);
    ts2.setNanos(60);
    
    /*
     * This really should have been assertFalse() because we started with timestamps that 
     * had different milliseconds 120055 and 120100. THe problem is that the timestamp's 
     * constructor converts the milliseconds passed into seconds and assigns the left-over
     * milliseconds to the nanos part of the timestamp. If setNanos() is called after that
     * then the previous value of nanos gets overwritten resulting in loss of milliseconds.
     */
    assertTrue(ts1.equals(ts2));
    
    /*
     * The right way to deal with timestamps when you have both milliseconds and nanos to assign
     * is to use the DateUtil.getTimestamp(long millis, int nanos).
     */
    ts1 = DateUtil.getTimestamp(120055,  60);
    ts2 = DateUtil.getTimestamp(120100, 60);
    assertFalse(ts1.equals(ts2));
    assertTrue(ts2.after(ts1));
  }
}

代码示例来源:origin: apache/phoenix

@Test
public void testDemonstrateSetNanosOnTimestampLosingMillis() {
  Timestamp ts1 = new Timestamp(120055);
  ts1.setNanos(60);
  
  Timestamp ts2 = new Timestamp(120100);
  ts2.setNanos(60);
  
  /*
   * This really should have been assertFalse() because we started with timestamps that 
   * had different milliseconds 120055 and 120100. THe problem is that the timestamp's 
   * constructor converts the milliseconds passed into seconds and assigns the left-over
   * milliseconds to the nanos part of the timestamp. If setNanos() is called after that
   * then the previous value of nanos gets overwritten resulting in loss of milliseconds.
   */
  assertTrue(ts1.equals(ts2));
  
  /*
   * The right way to deal with timestamps when you have both milliseconds and nanos to assign
   * is to use the DateUtil.getTimestamp(long millis, int nanos).
   */
  ts1 = DateUtil.getTimestamp(120055,  60);
  ts2 = DateUtil.getTimestamp(120100, 60);
  assertFalse(ts1.equals(ts2));
  assertTrue(ts2.after(ts1));
}

代码示例来源:origin: zstackio/zstack

@Override
  protected void scripts() {
    SessionInventory s = getSession(uuid);
    if (s == null) {
      throw new OperationFailureException(err(IdentityErrors.INVALID_SESSION,
          "Session expired"));
    }
    Timestamp curr = getCurrentSqlDate();
    if (curr.after(s.getExpiredDate())) {
      if (logger.isTraceEnabled()) {
        logger.debug(String.format("session expired[%s < %s] for account[uuid:%s]", curr,
            s.getExpiredDate(), s.getAccountUuid()));
      }
      logout(s.getUuid());
      throw new OperationFailureException(err(IdentityErrors.INVALID_SESSION, "Session expired"));
    }
  }
}.execute();

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

Timestamp alramTimeStamp = new Timestamp(calNow.getTimeInMillis());
Timestamp currentTimeStamp = new Timestamp(current_time);
if (alramTimeStamp.after(currentTimeStamp)) {
  alarmManager.set(AlarmManager.RTC_WAKEUP, calNow.getTimeInMillis(),
      operation_morn);
}

代码示例来源:origin: zstackio/zstack

private void sessionCheck() {
    if (msg.getSession() == null) {
      throw new ApiMessageInterceptionException(err(IdentityErrors.INVALID_SESSION,
          "session of message[%s] is null", msg.getMessageName()));
    }
    if (msg.getSession().getUuid() == null) {
      throw new ApiMessageInterceptionException(err(IdentityErrors.INVALID_SESSION,
          "session uuid is null"));
    }
    SessionInventory session = sessions.get(msg.getSession().getUuid());
    if (session == null) {
      SessionVO svo = dbf.findByUuid(msg.getSession().getUuid(), SessionVO.class);
      if (svo == null) {
        throw new ApiMessageInterceptionException(err(IdentityErrors.INVALID_SESSION,
            "Session expired"));
      }
      session = SessionInventory.valueOf(svo);
      sessions.put(session.getUuid(), session);
    }
    Timestamp curr = getCurrentSqlDate();
    if (curr.after(session.getExpiredDate())) {
      logger.debug(String.format("session expired[%s < %s] for account[uuid:%s]", curr,
          session.getExpiredDate(), session.getAccountUuid()));
      logOutSession(session.getUuid());
      throw new ApiMessageInterceptionException(err(IdentityErrors.INVALID_SESSION, "Session expired"));
    }
    this.session = session;
  }
}

代码示例来源:origin: k0kubun/gitstar-ranking

public boolean isUpdatedWithinDays(long days)
  {
    LocalDateTime daysAgo = LocalDateTime.now(ZoneId.of("UTC")).minusDays(days);
    return updatedAt.after(Timestamp.valueOf(daysAgo));
  }
}

代码示例来源:origin: apache/ofbiz-framework

public static boolean isDateAfterNow(Timestamp  date) {
  Timestamp now = UtilDateTime.nowTimestamp();
  if (date != null) {
    return date.after(now);
  }
  return false;
}
/** isTime returns true if string arguments hour, minute, and second form a valid time. */

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

/**
 * Returns if the {@link MethodIdentToSensorType} is active, meaning if the latest agent
 * registration included this instrumentation.
 *
 * @return True if the latest agent registration included the {@link MethodSensorTypeIdent}
 *         instrumentation on {@link MethodIdent}.
 */
public boolean isActive() {
  return timestamp.after(methodIdent.getTimeStamp()) && timestamp.after(methodIdent.getPlatformIdent().getTimeStamp());
}

代码示例来源:origin: sakaiproject/sakai

public boolean getReadAfterUpdate() {
  if (lastChecked == null) {
    return false;
  }
  return getLastChecked().after(gradebook.getLastUpdated());
}

代码示例来源:origin: approvals/ApprovalTests.Java

/***********************************************************************/
 public boolean isExtracted(AddDateAware object) throws IllegalArgumentException
 {
  ObjectUtils.assertInstance(AddDateAware.class, object);
  Timestamp addDate = ((AddDateAware) object).getAddDate();
  return (addDate == null) ? false : !addDate.after(date);
 }
}

代码示例来源:origin: com.j256.ormlite/ormlite-jdbc

@Override
public Object resultToSqlArg(FieldType fieldType, DatabaseResults results, int columnPos) throws SQLException {
  Timestamp timestamp = results.getTimestamp(columnPos);
  if (timestamp == null || ZERO_TIMESTAMP.after(timestamp)) {
    return null;
  } else {
    return timestamp.getTime();
  }
}

代码示例来源:origin: org.kuali.rice/rice-edl-impl

public int compare(Object o1, Object o2) {
    Timestamp date1 = ((Note) o1).getNoteCreateDate();
    Timestamp date2 = ((Note) o2).getNoteCreateDate();
    if (date1.before(date2)) {
      return returnCode * -1;
    } else if (date1.after(date2)) {
      return returnCode;
    } else {
      return 0;
    }
  }
});

代码示例来源:origin: de.tudarmstadt.ukp.wikipedia/de.tudarmstadt.ukp.wikipedia.wikimachine

public boolean checkTimestamp() {
  boolean result = !toTimestamp.equals(TIMESTAMP_UNDEFINED)
      && !fromTimestamp.equals(TIMESTAMP_UNDEFINED)
      && (this.toTimestamp.after(this.fromTimestamp)||this.toTimestamp.equals(this.fromTimestamp));
  if (!result) {
    logger.log("fromTimestamp is after toTimestamp");
  }
  return result;
}

代码示例来源:origin: j256/ormlite-core

@Test
public void testTimeStampDefault() throws Exception {
  Dao<TimeStampDefault, Object> dao = createDao(TimeStampDefault.class, true);
  TimeStampDefault foo = new TimeStampDefault();
  Timestamp before = new Timestamp(System.currentTimeMillis());
  Thread.sleep(1);
  assertEquals(1, dao.create(foo));
  Thread.sleep(1);
  Timestamp after = new Timestamp(System.currentTimeMillis());
  TimeStampDefault result = dao.queryForId(foo.id);
  assertTrue(result.timestamp.after(before));
  assertTrue(result.timestamp.before(after));
}

相关文章