Package java.sql

Examples of java.sql.Timestamp


        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);       
        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "char({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    public void testTimestampToDate() throws Exception {
        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);       
        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "date({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here


        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);       
        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "date({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    public void testTimestampToTime() throws Exception {
        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);       
        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "time({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

     
      Argument object = params.get(OBJECT);
      String objectName = (String) object.getArgumentValue().getValue();
     
      Argument start = params.get(STARTDATE);
      Timestamp startTime = (Timestamp) start.getArgumentValue().getValue();
      GregorianCalendar tempCalendar = (GregorianCalendar) GregorianCalendar.getInstance();
      tempCalendar.setTime(startTime);
      XMLGregorianCalendar startCalendar = factory.newXMLGregorianCalendar(tempCalendar);
     
      Argument end = params.get(ENDDATE);
      Timestamp endTime = (Timestamp) end.getArgumentValue().getValue();
      tempCalendar = (GregorianCalendar) GregorianCalendar.getInstance();
      tempCalendar.setTime(endTime);
      XMLGregorianCalendar endCalendar = factory.newXMLGregorianCalendar(tempCalendar);
     
      updatedResult = parent.getConnection().getUpdated(objectName, startCalendar, endCalendar);
View Full Code Here

        stat.execute("CREATE ALIAS testCall FOR \"" + getClass().getName() + ".testCall\"");
        call = conn.prepareCall("{CALL testCall(?,?,?)}");
        call.setInt("A", 100);
        call.setString(2, "abc");
        long t = System.currentTimeMillis();
        call.setTimestamp("C", new Timestamp(t));
        call.registerOutParameter(1, Types.INTEGER);
        call.registerOutParameter("B", Types.VARCHAR);
        call.executeUpdate();
        try {
            call.getTimestamp("C");
View Full Code Here

        rs.addColumn("B", Types.VARCHAR, 0, 0);
        rs.addColumn("C", Types.TIMESTAMP, 0, 0);
        if ("jdbc:columnlist:connection".equals(conn.getMetaData().getURL())) {
            return rs;
        }
        rs.addRow(a * 2, b.toUpperCase(), new Timestamp(c.getTime() + 1));
        return rs;
    }
View Full Code Here


    // Source = TIMESTAMP
   
    @Test public void testTimestampToString() throws Exception {
        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);       
        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "cast(TIMESTAMP '2003-11-01 12:05:02.0' AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

   * @return Outgoing value of target type
   * @throws TransformationException if value is an incorrect input type or
   * the transformation fails
   */
  public Object transformDirect(Object value) throws TransformationException {
    return new Timestamp( ((java.sql.Date) value).getTime() );
  }
View Full Code Here

     * @param Calendar object used to construct the Date object.
     * @return The parameter at the given index is returned as a Timestamp object.
     * @throws SQLException if param datatype is not TIMESTAMP
     */
    public Timestamp getTimestamp(int parameterIndex, java.util.Calendar cal) throws SQLException {
        Timestamp value = DataTypeTransformer.getTimestamp(getObject(parameterIndex));

        if (value == null) {
            return null;
        }
       
View Full Code Here

     * @param timeValue Time value, never null
     * @return Translated string
     */
    public String translateLiteralTime(Time timeValue) {
      if (!hasTimeType()) {
        return translateLiteralTimestamp(new Timestamp(timeValue.getTime()));
      }
        return "{t '" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

     * @param dateObject
     * @return Formatted string
     */
    public String formatDateValue(java.util.Date dateObject) {
        if (dateObject instanceof Timestamp && getTimestampNanoPrecision() < 9) {
          Timestamp ts = (Timestamp)dateObject;
          Timestamp newTs = new Timestamp(ts.getTime());
          if (getTimestampNanoPrecision() > 0) {
            int mask = (int)Math.pow(10, 9-getTimestampNanoPrecision());
            newTs.setNanos(ts.getNanos()/mask*mask);
          } else {
            newTs.setNanos(0);
          }
          dateObject = newTs;
        }
        return getTypeFacility().convertDate(dateObject, DEFAULT_TIME_ZONE, getDatabaseCalendar(), dateObject.getClass()).toString();       
    }   
View Full Code Here

TOP

Related Classes of java.sql.Timestamp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.