APISonar


java.sql.Time.Time

> java > sql > Time > Time
java APIs sql APIs Time APIs Time APIs

Example 1
public Time getCopy(Object object)
    {
        Time t = (Time) object;
        return t != null ? new Time(t.getTime()) : null;
    }
Example 2
public Time fromString(Class targetClass, String s)
    {
        if (s == null)
        {
            return null;
        }

        if (StringUtils.isNumeric(s))
        {
            return new Time(Long.parseLong(s));
        }
        Time t = Time.valueOf(s);
        return t;
    }
Example 3
public Time getInstance(Class<?> clazz)
    {
        return new Time(Integer.MAX_VALUE);
    }
Example 4
public void test18() {
        Time t = Time.valueOf("08:30:59");
        Time t2 = new Time(System.currentTimeMillis());
        assertTrue(t2.after(t), "Error t2.after(t) = false");
    }
Example 5
private void initTime() {
        Time time = new Time(System.currentTimeMillis());

        int hours = time.getHours();
        mHourSingleDigits = hours % 10;
        mHourTenDigits = hours / 10;

        int minutes = time.getMinutes();
        mMinSingleDigits = minutes % 10;
        mMinTenDigits = minutes / 10;

        int seconds = time.getSeconds();
        mSecSingleDigits = seconds % 10;
        mSecTenDigits = seconds / 10;
    }
Example 6
public void setTime(int parameterIndex, Time x) throws SQLException {
        if (x != null) { // Since Time is mutable, make a copy
            x = new Time(x.getTime());
        }
        setParameter(parameterIndex, x);
    }
Example 7
public void testTimeArray() throws Exception {
        Time[] times = new Time[]{new Time(System.currentTimeMillis()), new Time(123456789)};
        assertArrayEquals(times, marshalUnmarshal(times));
    }
Example 8
public Time getTime(String name)
    {
        return new Time(Long.parseLong(getFieldValue(name)));
    }
Example 9
public void testInternalPrecision() {
    long millis = System.currentTimeMillis();
    Time today = new Time(millis);
    Time after = new Time(today.getTime() + 1);
    Time before = new Time(today.getTime() - 1);

    // Note that Times internally retain millisecond precision
    assertTrue(after.after(today));
    assertTrue(before.before(today));
  }
Example 10
Time parseDate(String dateString) throws ParseException{
    Time time = null;
    try{
      SimpleDateFormat df = new SimpleDateFormat(MiscellaneousCommands.FORMAT);
      time = new Time(df.parse(dateString).getTime());
    }catch(Exception e){
      SimpleDateFormat df = new SimpleDateFormat(MiscellaneousCommands.ONLY_DATE_FORMAT);
      time = new Time(df.parse(dateString).getTime());
    }
    return time;
  }
Example 11
public void testToStringObject()
    {
        Assert.assertNull(accessor.toString(null));

        long l = System.currentTimeMillis();
        Time d = new Time(l);

        Assert.assertEquals("" + l, accessor.toString(d));
    }
Example 12
public void testSqlTime2Timestamp() {
		Time sqltime = new Time(time);
		Timestamp timestamp = SqlTimestampConverter.valueOf(sqltime);
		assertEquals(time, timestamp.getTime());
	}
Example 13
public void testSqlTime2JDateTime() {
		Time sqltime = new Time(time);
		JDateTime jdt = jDateTimeConverter.convert(sqltime);
		assertEquals(time, jdt.getTimeInMillis());
	}
Example 14
public static void main(String args[]) {
        Time t = new Time(System.currentTimeMillis());
        System.out.printf("%tr%n", t);
    }
Example 15
public void testThrownExceptionsWhenSettingTimeValues() throws SQLException {
        JdbcPreparedStatement jps = createJdbcPreparedStatement();
        Time time = new Time(4675000);

        SQLException sqle = expectThrows(SQLFeatureNotSupportedException.class, () -> jps.setObject(1, time, Types.INTEGER));
        assertEquals("Conversion from type [java.sql.Time] to [INTEGER] not supported", sqle.getMessage());
    }
Example 16
public void convert_sqlTime() {
        Time sqlTime = new Time(System.currentTimeMillis());
        String convert = convert(sqlTime);

        logger.debug("{}", convert);
    }
Example 17
static Time intToTime(int v, Calendar calendar) {
    if (calendar != null) {
      v -= calendar.getTimeZone().getOffset(v);
    }
    return new Time(v);
  }
Example 18
static Time toSqlTime(Timestamp ts, Calendar cal) {
    if (ts != null) {
      java.sql.Timestamp sqlTs = getAsSqlTimestamp(ts, cal);
      Time time = new Time(sqlTs.getHours(), sqlTs.getMinutes(), sqlTs.getSeconds());
      time.setTime(
          time.getTime() + TimeUnit.MILLISECONDS.convert(sqlTs.getNanos(), TimeUnit.NANOSECONDS));
      return time;
    }
    return null;
  }
Example 19
public void assertGetCalendarValueWithColumnLabelWithTime() throws SQLException {
        Calendar calendar = Calendar.getInstance();
        assertThat((Time) showOtherMergedResult.getCalendarValue("label", Time.class, calendar), is(new Time(0L)));
    }
Example 20
public void testTimeWithTrailingZeros() throws Exception {
        // Given
        Time expectedTime = new Time(
                new SimpleDateFormat(SQL_TIME_FORMAT)
                        .parse("10:20:30")
                        .getTime()
        );

        // When
        Time actualTime = DateHelper.parseSqlTime(expectedTime.toString());

        // Then
        assertSqlTimesEqual(expectedTime, actualTime);
    }
Example 21
public void testArrayFillFunctionTime() throws Exception {
        Connection conn = DriverManager.getConnection(getUrl());
        

        ResultSet rs;
        rs = conn.createStatement().executeQuery(
            "SELECT ARRAY_FILL(\"time\",3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'");
        assertTrue(rs.next());

        Object[] objects = new Object[]{new Time(1432102334184l), new Time(1432102334184l), new Time(1432102334184l)};

        Array array = conn.createArrayOf("TIME", objects);
        assertEquals(array, rs.getArray(1));
        assertFalse(rs.next());
    }
Example 22
private Time parseTime(String timeString)
    throws ParseException {

        // Return null if no time provided
        java.util.Date parsedDate = TimeField.parse(timeString);
        if (parsedDate == null)
            return null;

        // Convert to SQL Time 
        return new Time(parsedDate.getTime());

    }
Example 23
protected Time getTempTime(long value) {
    if (tempTime == null) {
      tempTime = new Time(value);
    } else {
      tempTime.setTime(value);
    }
    return tempTime;
  }
Example 24
public void testGetTimeParser_DefaultTimeZone() throws ParseException {
        Time time = new Time(DateUtil.getDateTimeParser("HH:mm:ss", PTime.INSTANCE).parseDateTime("00:00:00"));
        assertEquals(0, time.getTime());
    }
Example 25
public void testDefaultJavaSqlTimeSerialization() {
    Time now = new Time(1259875082000L);
    String json = gson.toJson(now);
    assertEquals("\"01:18:02 PM\"", json);
  }