Java Code Examples for java.sql.Time#after()

The following examples show how to use java.sql.Time#after() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimeHandlingTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: TimeHandlingTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: TimeHandlingTest.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}