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

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

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

Timestamp.before介绍

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

代码示例

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

private VirtualRouterVmVO findTheEarliestOne(List<VirtualRouterVmVO> vrs) {
  VirtualRouterVmVO vr = null;
  for (VirtualRouterVmVO v : vrs) {
    if (vr == null) {
      vr = v;
      continue;
    }
    vr = vr.getCreateDate().before(v.getCreateDate()) ? vr : v;
  }
  return vr;
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isIntervalSet() {
  if (null != fromDate) {
    if (null == toDate) {
      return true;
    } else {
      return fromDate.before(toDate);
    }
  } else if (null != toDate) {
    return true;
  }
  return false;
}

代码示例来源:origin: com.sap.cloud.servicesdk.prov/odata2.cdx

private boolean isModelUptoDate(String tenantId, Timestamp currentLastModifiedTimestamp) {
    Timestamp timestampInCache = tenantLastModifiedTime.get(tenantId);
    return timestampInCache != null && !(timestampInCache.before(currentLastModifiedTimestamp));
  }
}

代码示例来源:origin: epam/Wilma

/**
 * Shows whether the sequence is expired or not.
 * @param actualTimestamp is the timestamp of current time.
 * @return If the sequence is expired, its timestamp is before than the given timestamp.
 */
public boolean isExpired(final Timestamp actualTimestamp) {
  return this.timestamp.get().before(actualTimestamp);
}

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

public boolean hasExpired(long timeoutInSecs) {
    return new Timestamp(System.currentTimeMillis() - timeoutInSecs * 1000).before(createdAt);
  }
}

代码示例来源:origin: dkpro/dkpro-jwpl

private Integer calculateSnapshotsCount(Timestamp from, Timestamp to,
    Integer dayInterval) {
  Integer result = 0;
  for (Timestamp i = from; i.before(to); i = TimestampUtil
      .getNextTimestamp(i, dayInterval)) {
    result++;
  }
  return result;
}

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

public static boolean isDateBeforeNow(Timestamp  date) {
  Timestamp now = UtilDateTime.nowTimestamp();
  if (date != null) {
    return date.before(now);
  }
  return false;
}

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

/**
 * Reset the ship group's shipBeforeDate if it is after the parameter
 * @param newShipBeforeDate the ship group's shipBeforeDate to be reset
 */
public void resetShipBeforeDateIfAfter(Timestamp newShipBeforeDate) {
    if (newShipBeforeDate != null) {
    if ((this.shipBeforeDate == null) || (!this.shipBeforeDate.before(newShipBeforeDate))) {
      this.shipBeforeDate = (Timestamp) newShipBeforeDate.clone();
    }
  }
}

代码示例来源:origin: micromata/projectforge

/**
 * Start time of sheet must be fromDate or later and before toDate.
 * @param sheet
 */
public boolean matchWeek(TimesheetDO sheet)
{
 return sheet.getStartTime().before(fromDate) == false && sheet.getStartTime().before(toDate) == true;
}

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

public static boolean isValid(EndDateAware object, Date time)
 {
  return (object.getAddDate().before(time)
    && (object.getEndDate() == null || !object.getEndDate().before(time)));
 }
}

代码示例来源:origin: IQSS/dataverse

private boolean stale(DvObject dvObject) {
  Timestamp indexTime = dvObject.getIndexTime();
  Timestamp modificationTime = dvObject.getModificationTime();
  if (indexTime == null) {
    return true;
  } else if (indexTime.before(modificationTime)) {
    return true;
  }
  return false;
}

代码示例来源:origin: IQSS/dataverse

public AuthenticatedUser lookupUser( String apiToken ) {
  ApiToken tkn = findApiToken(apiToken);
  if ( tkn == null ) return null;
  
  if ( tkn.isDisabled() ) return null;
  if ( tkn.getExpireTime() != null ) {
    if ( tkn.getExpireTime().before( new Timestamp(new Date().getTime())) ) {
      em.remove(tkn);
      return null;
    }
  }
  
  return tkn.getAuthenticatedUser();
}

代码示例来源: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: apache/ofbiz-framework

public static boolean isSellable(GenericValue product, Timestamp atTime) {
  if (product != null) {
    Timestamp introDate = product.getTimestamp("introductionDate");
    Timestamp discDate = product.getTimestamp("salesDiscontinuationDate");
    if (introDate == null || introDate.before(atTime)) {
      if (discDate == null || discDate.after(atTime)) {
        return true;
      }
    }
  }
  return false;
}

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

public static boolean isValueActive(GenericValue datedValue, java.sql.Timestamp moment, String fromDateName, String thruDateName) {
  java.sql.Timestamp fromDate = datedValue.getTimestamp(fromDateName);
  java.sql.Timestamp thruDate = datedValue.getTimestamp(thruDateName);
  return (thruDate == null || thruDate.after(moment)) &&
      (fromDate == null || fromDate.before(moment) || fromDate.equals(moment));
}

代码示例来源:origin: IQSS/dataverse

private ApiToken getCurrentApiToken(AuthenticatedUser au) {
  if (au != null) {
    CommandContext ctxt = engine.getContext();
    ApiToken token = ctxt.authentication().findApiTokenByUser(au);
    if ((token == null) || (token.getExpireTime().before(new Date()))) {
      token = ctxt.authentication().generateApiTokenForUser(au);
    }
    return token;
  }
  return null;
}

代码示例来源:origin: org.astrogrid/astrogrid-dsa

/**
 * Deletes from the database all jobs for which the destruction time has
 * passed.
 */
public static void purge() throws PersistenceException {
 List<Job> jobs = Job.list();
 Date now = new Date();
 for (Job j : jobs) {
  if (j.getDestructionTime().before(now)) {
   Job.delete(j.getId());
   new ResultFile(j.getId()).delete();
  }
 }
}

代码示例来源:origin: cloudera-labs/envelope

@Override
public int compare(Row first, Row second) {
 Timestamp ts1 = first.getAs(field.name());
 Timestamp ts2 = second.getAs(field.name());
 
 if (ts1.before(ts2)) {
  return -1;
 } else if (ts1.after(ts2)) {
  return 1;
 } else {
  return 0;
 }
}

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

private static boolean isProductOld(String productId, Delegator delegator, Timestamp nowTimestamp) throws GenericEntityException {
  GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne();
  if (product != null) {
    Timestamp salesDiscontinuationDate = product.getTimestamp("salesDiscontinuationDate");
    if (salesDiscontinuationDate != null && salesDiscontinuationDate.before(nowTimestamp)) {
      return true;
    }
  }
  return false;
}

代码示例来源: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));
}

相关文章