下面列出了java.sql.Time#after ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Check the consistency of a ResultSet column that returns
* CURRENT TIME or a value set from CURRENT TIME.
*
* @param start Time the statement settng the value was executed
* @param end Time after first rs.next() or update statement was executed
* @param rs ResultSet holding the column, positioned on a row
* @param column Column with the timestamp.
* @return Returns the Time object obtained from the column.
* @throws SQLException
*/
private Time checkCurrentTimeValue(long start, long end,
ResultSet rs, int column) throws SQLException
{
Time tv = checkTimeValue(rs, column);
// The time returned should be between the value
// of start and end (inclusive of both)
Time st = getTime19700101(start, cal);
Time et = getTime19700101(end, cal);
if (st.after(et)) {
// Gone back in time!
// Well test was running around midnight and the
// time for the start time is equal to or before 23:59:59
// and end time is equal to or after 00:00:00
assertTrue("CURRENT TIME outside of range when test crossing midnight",
(tv.equals(st) || tv.after(st))
|| (tv.equals(et) || tv.before(et)));
}
else
{
// End time is after or equal to start time, expected case.
// The returned time must not be before the
// start time or after the end time.
assertFalse("CURRENT TIME before start of statement", tv.before(st));
assertFalse("CURRENT TIME after end of statement", tv.after(et));
}
return tv;
}
/**
* Check the consistency of a ResultSet column that returns
* CURRENT TIME or a value set from CURRENT TIME.
*
* @param start Time the statement settng the value was executed
* @param end Time after first rs.next() or update statement was executed
* @param rs ResultSet holding the column, positioned on a row
* @param column Column with the timestamp.
* @return Returns the Time object obtained from the column.
* @throws SQLException
*/
private Time checkCurrentTimeValue(long start, long end,
ResultSet rs, int column) throws SQLException
{
Time tv = checkTimeValue(rs, column);
// The time returned should be between the value
// of start and end (inclusive of both)
Time st = getTime19700101(start, cal);
Time et = getTime19700101(end, cal);
if (st.after(et)) {
// Gone back in time!
// Well test was running around midnight and the
// time for the start time is equal to or before 23:59:59
// and end time is equal to or after 00:00:00
assertTrue("CURRENT TIME outside of range when test crossing midnight",
(tv.equals(st) || tv.after(st))
|| (tv.equals(et) || tv.before(et)));
}
else
{
// End time is after or equal to start time, expected case.
// The returned time must not be before the
// start time or after the end time.
assertFalse("CURRENT TIME before start of statement", tv.before(st));
assertFalse("CURRENT TIME after end of statement", tv.after(et));
}
return tv;
}
/**
* Check the consistency of a ResultSet column that returns
* CURRENT TIME or a value set from CURRENT TIME.
*
* @param start Time the statement settng the value was executed
* @param end Time after first rs.next() or update statement was executed
* @param rs ResultSet holding the column, positioned on a row
* @param column Column with the timestamp.
* @return Returns the Time object obtained from the column.
* @throws SQLException
*/
private Time checkCurrentTimeValue(long start, long end,
ResultSet rs, int column) throws SQLException
{
Time tv = checkTimeValue(rs, column);
// The time returned should be between the value
// of start and end (inclusive of both)
Time st = getTime19700101(start, cal);
Time et = getTime19700101(end, cal);
if (st.after(et)) {
// Gone back in time!
// Well test was running around midnight and the
// time for the start time is equal to or before 23:59:59
// and end time is equal to or after 00:00:00
assertTrue("CURRENT TIME outside of range when test crossing midnight",
(tv.equals(st) || tv.after(st))
|| (tv.equals(et) || tv.before(et)));
}
else
{
// End time is after or equal to start time, expected case.
// The returned time must not be before the
// start time or after the end time.
assertFalse("CURRENT TIME before start of statement", tv.before(st));
assertFalse("CURRENT TIME after end of statement", tv.after(et));
}
return tv;
}