java.sql.Time Java Examples

The following examples show how to use java.sql.Time. 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 Project: jaybird   Author: FirebirdSQL   File: EncodingSpecificDatatypeCoderTest.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void decodeTime_calendar_boolean() throws Exception {
    final Calendar calendar = Calendar.getInstance();
    final Time value = new Time(System.currentTimeMillis());
    final Time response1 = new Time(System.currentTimeMillis() - 60 * 60 * 1000);
    final Time response2 = new Time(System.currentTimeMillis() + 60 * 60 * 1000);

    context.checking(new Expectations() {{
        oneOf(parentCoder).decodeTime(value, calendar, false); will(returnValue(response1));
        oneOf(parentCoder).decodeTime(value, calendar, true); will(returnValue(response2));
    }});

    Time result1 = coder.decodeTime(value, calendar, false);
    Time result2 = coder.decodeTime(value, calendar, true);

    assertSame(response1, result1);
    assertSame(response2, result2);
}
 
Example #2
Source Project: morpheus-core   Author: zavtech   File: DbSink.java    License: Apache License 2.0 6 votes vote down vote up
@Override
void apply(PreparedStatement stmt, int stmtIndex, DataFrameRow<R, C> row) {
    final R rowKey = row.key();
    try {
        switch (rowKeyType) {
            case BIT:       stmt.setBoolean(stmtIndex, rowKeyMapper.applyAsBoolean(rowKey));             break;
            case BOOLEAN:   stmt.setBoolean(stmtIndex, rowKeyMapper.applyAsBoolean(rowKey));             break;
            case TINYINT:   stmt.setInt(stmtIndex, rowKeyMapper.applyAsInt(rowKey));                     break;
            case SMALLINT:  stmt.setInt(stmtIndex, rowKeyMapper.applyAsInt(rowKey));                     break;
            case FLOAT:     stmt.setDouble(stmtIndex, rowKeyMapper.applyAsDouble(rowKey));               break;
            case INTEGER:   stmt.setInt(stmtIndex, rowKeyMapper.applyAsInt(rowKey));                     break;
            case BIGINT:    stmt.setLong(stmtIndex, rowKeyMapper.applyAsLong(rowKey));                   break;
            case DOUBLE:    stmt.setDouble(stmtIndex, rowKeyMapper.applyAsDouble(rowKey));               break;
            case DECIMAL:   stmt.setDouble(stmtIndex, rowKeyMapper.applyAsDouble(rowKey));               break;
            case VARCHAR:   stmt.setString(stmtIndex, (String)rowKeyMapper.apply(rowKey));          break;
            case DATE:      stmt.setDate(stmtIndex, (Date)rowKeyMapper.apply(rowKey));              break;
            case TIME:      stmt.setTime(stmtIndex, (Time)rowKeyMapper.apply(rowKey));              break;
            case DATETIME:  stmt.setTimestamp(stmtIndex, (Timestamp)rowKeyMapper.apply(rowKey));    break;
            default:    throw new IllegalStateException("Unsupported column type:" + rowKeyType);
        }
    } catch (Exception ex) {
        throw new DataFrameException("Failed to apply row key to SQL statement at " + rowKey, ex);
    }
}
 
Example #3
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: TestSQLDataImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void writeSQL(SQLOutput stream) throws SQLException {

    stream.writeString((String) types[stringPos]);
    stream.writeDate((Date) types[datePos]);
    stream.writeTime((Time) types[timePos]);
    stream.writeTimestamp((Timestamp) types[timestampPos]);
    stream.writeInt((Integer) types[intPos]);
    stream.writeLong((Long) types[longPos]);
    stream.writeShort((Short) types[shortPos]);
    stream.writeBigDecimal((BigDecimal) types[bigDecimalPos]);
    stream.writeDouble((Double) types[doublePos]);
    stream.writeBoolean((Boolean) types[booleanPos]);
    stream.writeFloat((Float) types[floatPos]);
    stream.writeByte((Byte) types[bytePos]);
    stream.writeBytes((byte[]) types[bytesPos]);
}
 
Example #4
Source Project: onetwo   Author: wayshall   File: DateUtilTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSqlTime(){
	Date now = new Date();
	Time time = new Time(now.getTime());
   	Time nowTime = new Time(now.getHours(), now.getMinutes(), now.getSeconds());
	String str = DateUtils.formatDateTime(time);
	System.out.println("time:"+DateUtils.format("h:mm a", new Date()));
	System.out.println("time:"+str);
	System.out.println("time:"+now.getTime());
	System.out.println("time:"+time.getTime());
	System.out.println("nowTime:"+nowTime.getTime());
	
	LocalTime jodaTime = LocalTime.fromDateFields(now);
	System.out.println("jodaTime:"+jodaTime.toString());
	System.out.println("jodaTime:"+now.getTime());
	System.out.println("jodaTime:"+jodaTime.getMillisOfDay());
}
 
Example #5
Source Project: easy-random   Author: j-easy   File: TimeRandomizersTest.java    License: MIT License 5 votes vote down vote up
static Object[][] generateSeededRandomizersAndTheirExpectedValues() {
    Calendar expectedCalendar = Calendar.getInstance();
    expectedCalendar.setTime(new Date(1718736844570L));

    GregorianCalendar expectedGregorianCalendar = new GregorianCalendar();
    expectedGregorianCalendar.setTimeInMillis(5106534569952410475L);

    return new Object[][] {
            { aNewDurationRandomizer(SEED), Duration.of(72L, ChronoUnit.HOURS) },
            { aNewDurationRandomizer(SEED, ChronoUnit.MINUTES), Duration.of(72L, ChronoUnit.MINUTES) },
            { aNewDurationRandomizer(SEED, ChronoUnit.MILLIS), Duration.of(72L, ChronoUnit.MILLIS) },
            { aNewLocalDateRandomizer(SEED), LocalDate.of(2024, Month.MARCH, 20) },
            { aNewMonthDayRandomizer(SEED), MonthDay.of(Month.MARCH, 20) },
            { aNewLocalTimeRandomizer(SEED), LocalTime.of(16, 42, 58) },
            { aNewPeriodRandomizer(SEED), Period.of(2024, 3, 20) },
            { aNewYearRandomizer(SEED), Year.of(2024) },
            { aNewYearMonthRandomizer(SEED), YearMonth.of(2024, Month.MARCH) },
            { aNewZoneOffsetRandomizer(SEED), ZoneOffset.ofTotalSeconds(28923) },
            { aNewCalendarRandomizer(SEED), expectedCalendar },
            { aNewDateRandomizer(SEED), new Date(1718736844570L) },
            { aNewGregorianCalendarRandomizer(SEED), expectedGregorianCalendar },
            { aNewInstantRandomizer(SEED), Instant.ofEpochSecond(1718736844L, 570000000) },
            { aNewLocalDateTimeRandomizer(SEED), LocalDateTime.of(2024, Month.MARCH, 20, 16, 42, 58, 0) },
            { aNewOffsetDateTimeRandomizer(SEED), OffsetDateTime.of(of(2024, Month.MARCH, 20, 16, 42, 58, 0), ofTotalSeconds(28923)) },
            { aNewOffsetTimeRandomizer(SEED), OffsetTime.of(LocalTime.of(16, 42, 58, 0), ofTotalSeconds(28923)) },
            { aNewSqlDateRandomizer(SEED), new java.sql.Date(1718736844570L) },
            { aNewSqlTimeRandomizer(SEED), new Time(1718736844570L) },
            { aNewSqlTimestampRandomizer(SEED), new Timestamp(1718736844570L) }
    };
}
 
Example #6
Source Project: kripton   Author: xcesco   File: BindBean2SharedPreferences.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * for attribute valueTimeList serialization
 */
protected String serializeValueTimeList(List<Time> value) {
  if (value==null) {
    return null;
  }
  KriptonJsonContext context=KriptonBinder.jsonBind();
  try (KriptonByteArrayOutputStream stream=new KriptonByteArrayOutputStream(); JacksonWrapperSerializer wrapper=context.createSerializer(stream)) {
    JsonGenerator jacksonSerializer=wrapper.jacksonGenerator;
    jacksonSerializer.writeStartObject();
    int fieldCount=0;
    if (value!=null)  {
      fieldCount++;
      int n=value.size();
      Time item;
      // write wrapper tag
      jacksonSerializer.writeFieldName("valueTimeList");
      jacksonSerializer.writeStartArray();
      for (int i=0; i<n; i++) {
        item=value.get(i);
        if (item==null) {
          jacksonSerializer.writeNull();
        } else {
          jacksonSerializer.writeString(SQLTimeUtils.write(item));
        }
      }
      jacksonSerializer.writeEndArray();
    }
    jacksonSerializer.writeEndObject();
    jacksonSerializer.flush();
    return stream.toString();
  } catch(Exception e) {
    e.printStackTrace();
    throw(new KriptonRuntimeException(e.getMessage()));
  }
}
 
Example #7
Source Project: spring4-understanding   Author: langtianya   File: OpPlusTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_binaryPlusWithTimeConverted() {

	final SimpleDateFormat format = new SimpleDateFormat("hh :--: mm :--: ss", Locale.ENGLISH);

	GenericConversionService conversionService = new GenericConversionService();
	conversionService.addConverter(new Converter<Time, String>() {
		@Override
		public String convert(Time source) {
			return format.format(source);
		}
	});

	StandardEvaluationContext evaluationContextConverter = new StandardEvaluationContext();
	evaluationContextConverter.setTypeConverter(new StandardTypeConverter(conversionService));

	ExpressionState expressionState = new ExpressionState(evaluationContextConverter);

	Time time = new Time(new Date().getTime());

	VariableReference var = new VariableReference("timeVar", -1);
	var.setValue(expressionState, time);

	StringLiteral n2 = new StringLiteral("\" is now\"", -1, "\" is now\"");
	OpPlus o = new OpPlus(-1, var, n2);
	TypedValue value = o.getValueInternal(expressionState);

	assertEquals(String.class, value.getTypeDescriptor().getObjectType());
	assertEquals(String.class, value.getTypeDescriptor().getType());
	assertEquals(format.format(time) + " is now", value.getValue());
}
 
Example #8
Source Project: commons-dbcp   Author: apache   File: DelegatingCallableStatement.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Time getTime(final String parameterName) throws SQLException {
    checkOpen();
    try {
        return getDelegateCallableStatement().getTime(parameterName);
    } catch (final SQLException e) {
        handleException(e);
        return null;
    }
}
 
Example #9
Source Project: enkan   Author: kawasima   File: CopyOptions.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * クラスに対応するデフォルトのコンバータを探します。
 *
 * @param clazz
 *            クラス
 * @return コンバータ
 */
protected Converter findDefaultConverter(final Class<?> clazz) {
    if (clazz == java.sql.Date.class) {
        return DEFAULT_DATE_CONVERTER;
    }
    if (clazz == Time.class) {
        return DEFAULT_TIME_CONVERTER;
    }
    if (java.util.Date.class.isAssignableFrom(clazz)) {
        return DEFAULT_TIMESTAMP_CONVERTER;
    }
    return null;
}
 
Example #10
Source Project: r-course   Author: joanby   File: CallableStatement.java    License: MIT License 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getTime(int)
 */
public Time getTime(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Time retValue = rs.getTime(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example #11
Source Project: sakai   Author: sakaiproject   File: CourseManagementAdministrationHibernateImpl.java    License: Educational Community License v2.0 5 votes vote down vote up
public Meeting newSectionMeeting(String sectionEid, String location, Time startTime, Time finishTime, String notes) {
	Section section = (Section)getObjectByEid(sectionEid, SectionCmImpl.class.getName());
	MeetingCmImpl meeting = new MeetingCmImpl(section, location, startTime, finishTime, notes);
	meeting.setCreatedBy(authn.getUserEid());
	meeting.setCreatedDate(new Date());
	Set<Meeting> meetings = section.getMeetings();
	if(meetings == null) {
		meetings = new HashSet<Meeting>();
		section.setMeetings(meetings);
	}
	return meeting;
}
 
Example #12
Source Project: flink   Author: flink-tpc-ds   File: HBaseTypeUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Deserialize byte array to Java Object with the given type.
 */
public static Object deserializeToObject(byte[] value, int typeIdx, Charset stringCharset) {
	switch (typeIdx) {
		case 0: // byte[]
			return value;
		case 1: // String
			return new String(value, stringCharset);
		case 2: // byte
			return value[0];
		case 3:
			return Bytes.toShort(value);
		case 4:
			return Bytes.toInt(value);
		case 5:
			return Bytes.toLong(value);
		case 6:
			return Bytes.toFloat(value);
		case 7:
			return Bytes.toDouble(value);
		case 8:
			return Bytes.toBoolean(value);
		case 9: // sql.Timestamp encoded as long
			return new Timestamp(Bytes.toLong(value));
		case 10: // sql.Date encoded as long
			return new Date(Bytes.toLong(value));
		case 11: // sql.Time encoded as long
			return new Time(Bytes.toLong(value));
		case 12:
			return Bytes.toBigDecimal(value);
		case 13:
			return new BigInteger(value);

		default:
			throw new IllegalArgumentException("unsupported type index:" + typeIdx);
	}
}
 
Example #13
Source Project: spliceengine   Author: splicemachine   File: Cursor.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private Time getTIME(int column, Calendar cal) throws SqlException {
    try {
        return com.splicemachine.db.client.am.DateTime.timeBytesToTime(dataBuffer_,
                columnDataPosition_[column - 1],
                cal,
                charsetName_[column - 1]);
    } catch (UnsupportedEncodingException e) {
         throw new SqlException(agent_.logWriter_, 
             new ClientMessageId(SQLState.UNSUPPORTED_ENCODING),
             "TIME", "java.sql.Time", e);
    }
}
 
Example #14
Source Project: spliceengine   Author: splicemachine   File: ManyMethods.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public String isNull(Time value)
{
	if (value == null)
		return "Time is null";
	else
		return "Time is not null";
}
 
Example #15
Source Project: Flink-CEPplus   Author: ljygz   File: HBaseRowInputFormat.java    License: Apache License 2.0 5 votes vote down vote up
private Object deserialize(byte[] value, int typeIdx) {
	switch (typeIdx) {
		case 0: // byte[]
			return value;
		case 1:
			return new String(value, stringCharset);
		case 2: // byte
			return value[0];
		case 3:
			return Bytes.toShort(value);
		case 4:
			return Bytes.toInt(value);
		case 5:
			return Bytes.toLong(value);
		case 6:
			return Bytes.toFloat(value);
		case 7:
			return Bytes.toDouble(value);
		case 8:
			return Bytes.toBoolean(value);
		case 9: // sql.Timestamp encoded as long
			return new Timestamp(Bytes.toLong(value));
		case 10: // sql.Date encoded as long
			return new Date(Bytes.toLong(value));
		case 11: // sql.Time encoded as long
			return new Time(Bytes.toLong(value));
		case 12:
			return Bytes.toBigDecimal(value);
		case 13:
			return new BigInteger(value);

		default:
			throw new IllegalArgumentException("Unknown type index " + typeIdx);
	}
}
 
Example #16
Source Project: sakai   Author: sakaiproject   File: SectionManagerImpl.java    License: Educational Community License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void updateSection(String sectionUuid, String title,
		Integer maxEnrollments, String location, Time startTime,
		Time endTime, boolean monday, boolean tuesday,
		boolean wednesday, boolean thursday, boolean friday,
		boolean saturday, boolean sunday) {
	// Create a list of meetings with a single meeting
	List<Meeting> meetings = new ArrayList<Meeting>();
	MeetingImpl meeting = new MeetingImpl(location, startTime, endTime, monday, tuesday, wednesday, thursday, friday, saturday, sunday);
	meetings.add(meeting);

	// Update the section with a single meeting
	updateSection(sectionUuid, title, maxEnrollments, meetings);
}
 
Example #17
Source Project: sakai   Author: sakaiproject   File: SectionDecorator.java    License: Educational Community License v2.0 5 votes vote down vote up
/**
 * Compares SectionDecorators by the section's first meeting times.
 *
 * @param sortAscending
 * @return
 */
public static final Comparator<SectionDecorator> getTimeComparator(final boolean sortAscending) {
    return new Comparator<SectionDecorator>() {
        public int compare(SectionDecorator section1, SectionDecorator section2) {

                // First compare the category name, then compare the time
                int categoryNameComparison = section1.getCategory().compareTo(section2.getCategory());
                if(categoryNameComparison == 0) {
                    // These are in the same category, so compare by the first meeting time
                    List meetings1 = section1.getDecoratedMeetings();
                    List meetings2 = section2.getDecoratedMeetings();

                    MeetingDecorator meeting1 = (MeetingDecorator)meetings1.get(0);
                    MeetingDecorator meeting2 = (MeetingDecorator)meetings2.get(0);

                    Time startTime1 = meeting1.getStartTime();
                    Time startTime2 = meeting2.getStartTime();

                    if(startTime1 == null && startTime2 != null) {
                        return sortAscending? -1 : 1 ;
                    }
                    if(startTime2 == null && startTime1 != null) {
                        return sortAscending? 1 : -1 ;
                    }

                    if(startTime1 == null && startTime2 == null ||
                            startTime1.equals(startTime2)) {
                        return getTitleComparator(sortAscending).compare(section1, section2);
                    }
                    return sortAscending ? startTime1.compareTo(startTime2) : startTime2.compareTo(startTime1);
                } else {
                    return categoryNameComparison;
                }
        }
    };
}
 
Example #18
Source Project: spliceengine   Author: splicemachine   File: Wrapper41Test.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private void    vetWrappedInteger( Wrapper41 wrapper, int colID, String colName ) throws Exception
{
    vetWrapperOK
        (
         wrapper,
         colID,
         colName,
         _rowOfNulls ? null : "1",
         new Class[] { String.class, BigDecimal.class, Byte.class, Short.class, Integer.class, Long.class, Number.class, Object.class }
         );
    vetWrapperOK
        (
         wrapper,
         colID,
         colName,
         _rowOfNulls ? null : "1.0",
         new Class[] { Float.class, Double.class }
         );
    vetWrapperOK
        (
         wrapper,
         colID,
         colName,
         _rowOfNulls ? null : "true",
         new Class[] { Boolean.class }
         );
    
    vetNoWrapper
        (
         wrapper,
         colID,
         colName,
         new Class[] { Date.class, Time.class, Timestamp.class, Blob.class, Clob.class, _byteArrayClass, getClass() }
         );
}
 
Example #19
Source Project: scriptella-etl   Author: scriptella   File: JdbcTypesConverter.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@link java.util.Date} or its descendant as a statement parameter.
 */
protected void setDateObject(final PreparedStatement ps, final int index, final Date date) throws SQLException {
    if (date instanceof Timestamp) {
        ps.setTimestamp(index, (Timestamp) date);
    } else if (date instanceof java.sql.Date) {
        ps.setDate(index, (java.sql.Date) date);
    } else if (date instanceof Time) {
        ps.setTime(index, (Time) date);
    } else {
        ps.setTimestamp(index, new Timestamp(date.getTime()));
    }
}
 
Example #20
Source Project: entando-core   Author: entando   File: TableDataUtils.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private static String getTimeAsString(Time time) {
    if (null == time) {
        return null;
    }
    Date date = new Date(time.getTime());
    return getDateAsString(date);
}
 
Example #21
Source Project: presto   Author: prestosql   File: TestField.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTime()
{
    Type type = TIME;
    Time expected = new Time(new GregorianCalendar(1970, 0, 1, 12, 30, 0).getTime().getTime());
    Field f1 = new Field(70200000L, type);
    assertEquals(f1.getTime(), expected);
    assertEquals(f1.getObject(), expected);
    assertEquals(f1.getType(), type);

    Field f2 = new Field(f1);
    assertEquals(f2, f1);
}
 
Example #22
Source Project: framework   Author: Odoo-mobile   File: TimeTypeAdapter.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override public synchronized Time read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }
  try {
    Date date = format.parse(in.nextString());
    return new Time(date.getTime());
  } catch (ParseException e) {
    throw new JsonSyntaxException(e);
  }
}
 
Example #23
Source Project: gemfirexd-oss   Author: gemxd   File: SQLTimestamp.java    License: Apache License 2.0 5 votes vote down vote up
/**
	getTime returns the time portion of the timestamp
	Date is set to 1970-01-01
	Since Time is a JDBC object we use the JDBC definition
	for the date portion.  See JDBC API Tutorial, 47.3.12.
	@exception StandardException thrown on failure
 */
public Time	getTime( Calendar cal) throws StandardException
{
	if (isNull())
		return null;
       
       // Derby's SQL TIMESTAMP type supports resolution
       // to nano-seconds so ensure the Time object
       // maintains that since it has milli-second
       // resolutiuon.
       return SQLTime.getTime(cal, encodedTime, nanos);
}
 
Example #24
Source Project: flink   Author: apache   File: SqlTimeParserTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Time[] getValidTestResults() {
	return new Time[] {
		Time.valueOf("00:00:00"), Time.valueOf("02:42:25"), Time.valueOf("14:15:51"),
		Time.valueOf("18:00:45"), Time.valueOf("23:59:58"), Time.valueOf("0:0:0")
	};
}
 
Example #25
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: StubSyncResolver.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setTime(String parameterName, Time x, Calendar cal) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #26
Source Project: r-course   Author: joanby   File: PreparedStatement.java    License: MIT License 4 votes vote down vote up
public void setObject(int parameterIndex, Object parameterObj) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        if (parameterObj == null) {
            setNull(parameterIndex, java.sql.Types.OTHER);
        } else {
            if (parameterObj instanceof Byte) {
                setInt(parameterIndex, ((Byte) parameterObj).intValue());
            } else if (parameterObj instanceof String) {
                setString(parameterIndex, (String) parameterObj);
            } else if (parameterObj instanceof BigDecimal) {
                setBigDecimal(parameterIndex, (BigDecimal) parameterObj);
            } else if (parameterObj instanceof Short) {
                setShort(parameterIndex, ((Short) parameterObj).shortValue());
            } else if (parameterObj instanceof Integer) {
                setInt(parameterIndex, ((Integer) parameterObj).intValue());
            } else if (parameterObj instanceof Long) {
                setLong(parameterIndex, ((Long) parameterObj).longValue());
            } else if (parameterObj instanceof Float) {
                setFloat(parameterIndex, ((Float) parameterObj).floatValue());
            } else if (parameterObj instanceof Double) {
                setDouble(parameterIndex, ((Double) parameterObj).doubleValue());
            } else if (parameterObj instanceof byte[]) {
                setBytes(parameterIndex, (byte[]) parameterObj);
            } else if (parameterObj instanceof java.sql.Date) {
                setDate(parameterIndex, (java.sql.Date) parameterObj);
            } else if (parameterObj instanceof Time) {
                setTime(parameterIndex, (Time) parameterObj);
            } else if (parameterObj instanceof Timestamp) {
                setTimestamp(parameterIndex, (Timestamp) parameterObj);
            } else if (parameterObj instanceof Boolean) {
                setBoolean(parameterIndex, ((Boolean) parameterObj).booleanValue());
            } else if (parameterObj instanceof InputStream) {
                setBinaryStream(parameterIndex, (InputStream) parameterObj, -1);
            } else if (parameterObj instanceof java.sql.Blob) {
                setBlob(parameterIndex, (java.sql.Blob) parameterObj);
            } else if (parameterObj instanceof java.sql.Clob) {
                setClob(parameterIndex, (java.sql.Clob) parameterObj);
            } else if (this.connection.getTreatUtilDateAsTimestamp() && parameterObj instanceof java.util.Date) {
                setTimestamp(parameterIndex, new Timestamp(((java.util.Date) parameterObj).getTime()));
            } else if (parameterObj instanceof BigInteger) {
                setString(parameterIndex, parameterObj.toString());
            } else {
                setSerializableObject(parameterIndex, parameterObj);
            }
        }
    }
}
 
Example #27
Source Project: sinavi-jfw   Author: ctc-g   File: Dates.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 現在の時間から生成されるjava.sql.Timeを返します.
 * @return 現在の時間を示すjava.sql.Time
 */
public static Time getSqlTime() {

    return new Time(System.currentTimeMillis());
}
 
Example #28
Source Project: gemfirexd-oss   Author: gemxd   File: ClientResultSet.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public final Time getTime(int columnIndex) throws SQLException {
  return getTime(columnIndex, null);
}
 
Example #29
Source Project: ignite   Author: apache   File: SqlListenerUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * @param writer Writer.
 * @param obj Object to write.
 * @param binObjAllow Allow to write non plain objects.
 * @throws BinaryObjectException On error.
 */
public static void writeObject(BinaryWriterExImpl writer, @Nullable Object obj, boolean binObjAllow)
    throws BinaryObjectException {
    if (obj == null) {
        writer.writeByte(GridBinaryMarshaller.NULL);

        return;
    }

    Class<?> cls = obj.getClass();

    if (cls == Boolean.class)
        writer.writeBooleanFieldPrimitive((Boolean)obj);
    else if (cls == Byte.class)
        writer.writeByteFieldPrimitive((Byte)obj);
    else if (cls == Character.class)
        writer.writeCharFieldPrimitive((Character)obj);
    else if (cls == Short.class)
        writer.writeShortFieldPrimitive((Short)obj);
    else if (cls == Integer.class)
        writer.writeIntFieldPrimitive((Integer)obj);
    else if (cls == Long.class)
        writer.writeLongFieldPrimitive((Long)obj);
    else if (cls == Float.class)
        writer.writeFloatFieldPrimitive((Float)obj);
    else if (cls == Double.class)
        writer.writeDoubleFieldPrimitive((Double)obj);
    else if (cls == String.class)
        writer.doWriteString((String)obj);
    else if (cls == BigDecimal.class)
        writer.doWriteDecimal((BigDecimal)obj);
    else if (cls == UUID.class)
        writer.writeUuid((UUID)obj);
    else if (cls == Time.class)
        writer.writeTime((Time)obj);
    else if (cls == Timestamp.class)
        writer.writeTimestamp((Timestamp)obj);
    else if (cls == java.sql.Date.class || cls == java.util.Date.class)
        writer.writeDate((java.util.Date)obj);
    else if (cls == boolean[].class)
        writer.writeBooleanArray((boolean[])obj);
    else if (cls == byte[].class)
        writer.writeByteArray((byte[])obj);
    else if (cls == char[].class)
        writer.writeCharArray((char[])obj);
    else if (cls == short[].class)
        writer.writeShortArray((short[])obj);
    else if (cls == int[].class)
        writer.writeIntArray((int[])obj);
    else if (cls == long[].class)
        writer.writeLongArray((long[])obj);
    else if (cls == float[].class)
        writer.writeFloatArray((float[])obj);
    else if (cls == double[].class)
        writer.writeDoubleArray((double[])obj);
    else if (cls == String[].class)
        writer.writeStringArray((String[])obj);
    else if (cls == BigDecimal[].class)
        writer.writeDecimalArray((BigDecimal[])obj);
    else if (cls == UUID[].class)
        writer.writeUuidArray((UUID[])obj);
    else if (cls == Time[].class)
        writer.writeTimeArray((Time[])obj);
    else if (cls == Timestamp[].class)
        writer.writeTimestampArray((Timestamp[])obj);
    else if (cls == java.util.Date[].class || cls == java.sql.Date[].class)
        writer.writeDateArray((java.util.Date[])obj);
    else if (binObjAllow)
        writer.writeObjectDetached(obj);
    else
        throw new BinaryObjectException("Custom objects are not supported");
}
 
Example #30
Source Project: dragonwell8_jdk   Author: alibaba   File: StubBaseRowSet.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void updateTime(String columnLabel, Time x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}