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

x33g5p2x  于2022-01-17 转载在 其他  
字(13.1k)|赞(0)|评价(0)|浏览(210)

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

Date.after介绍

暂无

代码示例

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

/**
 * Compare two Date values and return min or max 
 */
public static Date minMaxDate(Date d1, String s, boolean max) {
 Date d2 = Utils.toDate(s);
 if(d1 == null) {
  return d2;
 } else if(d2 == null) {
  return d1;
 }    
 if((max && d1.before(d2)) || (!max && d1.after(d2))) {
  return d2;
 }
 return d1;
}

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

maxDateValue = java.sql.Date.valueOf(maxValueString);
if (maxDateValue == null || colDateValue.after(maxDateValue)) {
  return colDateValue.toString();

代码示例来源:origin: benas/random-beans

@Override
protected void checkValues() {
  if (min.after(max)) {
    throw new IllegalArgumentException("max must be after min");
  }
}

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

@Test
public void testUpsertDateValues() throws Exception {
  long ts = nextTimestamp();
  Date now = new Date(System.currentTimeMillis());
  ensureTableCreated(getUrl(),TestUtil.PTSDB_NAME,null, ts-2);
  Properties props = new Properties();
  props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 1)); // Execute at timestamp 1
  Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
  String dateString = "1999-01-01 02:00:00";
  PreparedStatement upsertStmt = conn.prepareStatement("upsert into ptsdb(inst,host,date) values('aaa','bbb',to_date('" + dateString + "'))");
  int rowsInserted = upsertStmt.executeUpdate();
  assertEquals(1, rowsInserted);
  upsertStmt = conn.prepareStatement("upsert into ptsdb(inst,host,date) values('ccc','ddd',current_date())");
  rowsInserted = upsertStmt.executeUpdate();
  assertEquals(1, rowsInserted);
  conn.commit();
  
  props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 1
  conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
  String select = "SELECT date,current_date() FROM ptsdb";
  ResultSet rs = conn.createStatement().executeQuery(select);
  Date then = new Date(System.currentTimeMillis());
  assertTrue(rs.next());
  Date date = DateUtil.parseDate(dateString);
  assertEquals(date,rs.getDate(1));
  assertTrue(rs.next());
  assertTrue(rs.getDate(1).after(now) && rs.getDate(1).before(then));
  assertFalse(rs.next());
}

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

assertEquals(indexName + "1", rs.getString(1));
Date d1 = rs.getDate(2);
assertTrue(d1.after(d0));
assertTrue(rs.next());
assertEquals(indexName + "2", rs.getString(1));
Date d2 = rs.getDate(2);
assertTrue(d2.after(d1));
assertFalse(rs.next());

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

@Test
public void testUpsertDateValues() throws Exception {
  String tableName = generateUniqueName();
  Date now = new Date(EnvironmentEdgeManager.currentTimeMillis());
  ensureTableCreated(getUrl(), tableName, TestUtil.PTSDB_NAME, null, null, null);
  Properties props = new Properties();
  Connection conn = DriverManager.getConnection(getUrl(), props);
  String dateString = "1999-01-01 02:00:00";
  PreparedStatement upsertStmt = conn.prepareStatement("upsert into " + tableName + "(inst,host,\"DATE\") values('aaa','bbb',to_date('" + dateString + "'))");
  int rowsInserted = upsertStmt.executeUpdate();
  assertEquals(1, rowsInserted);
  upsertStmt = conn.prepareStatement("upsert into " + tableName + "(inst,host,\"DATE\") values('ccc','ddd',current_date())");
  rowsInserted = upsertStmt.executeUpdate();
  assertEquals(1, rowsInserted);
  conn.commit();
  
  conn = DriverManager.getConnection(getUrl(), props);
  String select = "SELECT \"DATE\",current_date() FROM " + tableName;
  ResultSet rs = conn.createStatement().executeQuery(select);
  Date then = new Date(EnvironmentEdgeManager.currentTimeMillis());
  assertTrue(rs.next());
  Date date = DateUtil.parseDate(dateString);
  assertEquals(date,rs.getDate(1));
  assertTrue(rs.next());
  assertTrue(rs.getDate(1).after(now) && rs.getDate(1).before(then));
  assertFalse(rs.next());
}

代码示例来源:origin: org.openurp.edu.base/openurp-edu-base-api4j

public boolean isMatchIn(java.sql.Date d) {
 if (!this.beginOn.after(d)) {
  if (null == endOn) return true;
  else return !d.after(this.endOn);
 }else {
  return false;
 }
}

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

assertEquals(null, rs.getString(1));
assertEquals(ROW6, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertEquals(null, rs.getBigDecimal(4));
assertEquals(null, rs.getString(1));
assertEquals(ROW7, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(70).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(null, rs.getString(1));
assertEquals(ROW8, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(60).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(null, rs.getString(1));
assertEquals(ROW9, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(50).compareTo(rs.getBigDecimal(4)) == 0);

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

assertTrue(d >= 0.0 && d <= 1.0);
Date date = rs.getDate(4);
assertTrue(date.after(new Date(System.currentTimeMillis())));
assertEquals("eee",rs.getString(5));
assertEquals("f",rs.getString(6));

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

assertEquals(null, rs.getString(1));
assertEquals(ROW6, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertEquals(null, rs.getBigDecimal(4));
assertEquals(null, rs.getString(1));
assertEquals(ROW7, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(70).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(null, rs.getString(1));
assertEquals(ROW8, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(60).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(null, rs.getString(1));
assertEquals(ROW9, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(50).compareTo(rs.getBigDecimal(4)) == 0);

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

assertEquals(null, rs.getString(1));
assertEquals(ROW6, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertEquals(null, rs.getBigDecimal(4));
assertEquals(null, rs.getString(1));
assertEquals(ROW7, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(70).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(null, rs.getString(1));
assertEquals(ROW8, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(60).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(null, rs.getString(1));
assertEquals(ROW9, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(50).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(ROW6, rs.getString(1));
assertEquals(null, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertEquals(null, rs.getBigDecimal(4));
assertEquals(ROW7, rs.getString(1));
assertEquals(null, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(70).compareTo(rs.getBigDecimal(4)) == 0);

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

assertEquals(null, rs.getString(1));
assertEquals(ROW6, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertEquals(null, rs.getBigDecimal(4));
assertEquals(null, rs.getString(1));
assertEquals(ROW7, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(70).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(null, rs.getString(1));
assertEquals(ROW8, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(60).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(null, rs.getString(1));
assertEquals(ROW9, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(50).compareTo(rs.getBigDecimal(4)) == 0);
assertEquals(ROW6, rs.getString(1));
assertEquals(null, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertEquals(null, rs.getBigDecimal(4));
assertEquals(ROW7, rs.getString(1));
assertEquals(null, rs.getString(2));
assertTrue(rs.getDate(3).after(now) && rs.getDate(3).before(then));
assertTrue(BigDecimal.valueOf(70).compareTo(rs.getBigDecimal(4)) == 0);

代码示例来源:origin: io.github.benas/random-beans

@Override
protected void checkValues() {
  if (min.after(max)) {
    throw new IllegalArgumentException("max must be after min");
  }
}

代码示例来源:origin: org.openurp.edu.base/openurp-edu-base-api4j

public boolean after(org.openurp.edu.base.model.Semester semester) {
 return beginOn.after(semester.getEndOn());
}

代码示例来源:origin: org.kuali.kfs/kfs-module-endow

protected List<TransactionArchive> retrieveTransactionArchives(String sourceKemid, Date lastProcessDate, String targetEtranCode) {
  KualiDecimal totalCashIncomeEtranCode = KualiDecimal.ZERO;
  List<TransactionArchive> transactionArchiveList = null;
  Map fieldValues = new HashMap();
  fieldValues.put(EndowPropertyConstants.KEMID, sourceKemid);
  fieldValues.put(EndowPropertyConstants.TRANSACTION_LINE_ENDOWMENT_TRANSACTION_CODE, targetEtranCode);
  transactionArchiveList = (List) businessObjectService.findMatching(TransactionArchive.class, fieldValues);
  for (TransactionArchive transactionArchive : transactionArchiveList) {
    if (!transactionArchive.getPostedDate().after(lastProcessDate)) {
      transactionArchiveList.remove(transactionArchive);
    }
  }
  return transactionArchiveList;
}

代码示例来源:origin: org.apache.portals.jetspeed-2/jetspeed-security

public void setExpirationDate(Date expirationDate)
{
  checkUpdateState();
  this.expirationDate = expirationDate;
  if (expirationDate != null && new Date(new java.util.Date().getTime()).after(expirationDate))
  {
    setExpired(true);
  }
  else
  {
    setExpired(false);
  }
}

代码示例来源:origin: org.kuali.kfs/kfs-core

/**
 * Checks to see if the end date is after the begin date
 * 
 * @param begin
 * @param end
 * @param propertyName
 * @return true if end is after begin, false otherwise
 */
protected boolean checkEndAfterBegin(Date begin, Date end, String propertyName) {
  boolean success = true;
  if (ObjectUtils.isNotNull(begin) && ObjectUtils.isNotNull(end) && !end.after(begin)) {
    putFieldError(propertyName, KFSKeyConstants.ERROR_ENDING_DATE_NOT_AFTER_BEGIN);
    success = false;
  }
  return success;
}

代码示例来源:origin: org.kuali.kfs/kfs-core

/**
 * This method checks if customer end date is valid: 1. if a new address is being added, customer end date must be a future date
 * 2. if inactivating an address, customer end date must be current or future date
 * 
 * @param endDate
 * @param canBeTodaysDateFlag
 * @return True if endDate is valid.
 */
public boolean checkEndDateIsValid(Date endDate, boolean canBeTodaysDateFlag) {
  boolean isValid = true;
  if (ObjectUtils.isNull(endDate))
    return isValid;
  Timestamp today = dateTimeService.getCurrentTimestamp();
  today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH).getTime());
  // end date must be todays date or future date
  if (canBeTodaysDateFlag) {
    if (endDate.before(today)) {
      isValid = false;
    }
  } // end date must be a future date
  else {
    if (!endDate.after(today)) {
      isValid = false;
    }
  }
  return isValid;
}

代码示例来源:origin: org.kuali.kfs/kfs-core

/**
 * This method checks to see if the account expiration date is today's date or earlier
 * 
 * @param newAccount
 * @return fails if the expiration date is null or after today's date
 */
protected boolean checkAccountExpirationDateValidTodayOrEarlier(Account newAccount) {
  // get today's date, with no time component
  Date todaysDate = new Date(getDateTimeService().getCurrentDate().getTime());
  todaysDate.setTime(DateUtils.truncate(todaysDate, Calendar.DAY_OF_MONTH).getTime());
  // TODO: convert this to using Wes' Kuali DateUtils once we're using Date's instead of Timestamp
  
  // get the expiration date, if any
  Date expirationDate = newAccount.getAccountExpirationDate();
  if (ObjectUtils.isNull(expirationDate)) {
    putFieldError("accountExpirationDate", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
    return false;
  }
  // when closing an account, the account expiration date must be the current date or earlier
  expirationDate.setTime(DateUtils.truncate(expirationDate, Calendar.DAY_OF_MONTH).getTime());
  if (expirationDate.after(todaysDate)) {
    putFieldError("accountExpirationDate", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
    return false;
  }
  return true;
}

代码示例来源:origin: org.kuali.kfs/kfs-module-endow

/**
 * Validates that the total of all non-terminated records is 1 (100%).
 * 
 * @return true if valid, false otherwise
 */
private boolean validatePayoutInstructionsPercentTotal() {
  boolean isValid = true;
  DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
  Date currentDate = dateTimeService.getCurrentSqlDate();
  KualiDecimal total = KualiDecimal.ZERO;
  for (KemidPayoutInstruction payoutInstruction : newKemid.getKemidPayoutInstructions()) {
    if (payoutInstruction.getEndDate() == null || payoutInstruction.getEndDate().after(currentDate)) {
      total = total.add(payoutInstruction.getPercentOfIncomeToPayToKemid());
    }
  }
  KualiDecimal one = new KualiDecimal(1);
  if (one.compareTo(total) != 0) {
    putFieldError(EndowPropertyConstants.KEMID_PAY_INSTRUCTIONS_TAB, EndowKeyConstants.KEMIDConstants.ERROR_KEMID_TOTAL_OFF_ALL_PAYOUT_RECORDS_MUST_BE_ONE);
    isValid = false;
  }
  return isValid;
}

相关文章