Package java.sql

Examples of java.sql.Timestamp


                buff.append(IOUtils.isReadOnly(file) ? "r-" : "rw");
                buff.append(' ');
                buff.append(String.format("%10d", IOUtils.length(file)));
                buff.append(' ');
                long lastMod = IOUtils.getLastModified(file);
                buff.append(new Timestamp(lastMod).toString());
                buff.append(' ');
                buff.append(IOUtils.getFileName(file));
                println(buff.toString());
            }
        } else if ("mkdir".equals(c)) {
View Full Code Here


        Date d = Date.valueOf("2001-02-03");
        byte[] b = {(byte) 0xab};
        Object[] a = {1, 2};
        Time t = Time.valueOf("10:20:30");
        Timestamp ts = Timestamp.valueOf("2002-03-04 10:20:30");
        rs.addRow(1, b, true, d, "10.3", Math.PI, "-3", a, t, ts);

        rs.next();

        assertEquals(1, rs.getLong(1));
View Full Code Here

        deleteDb("cases");
        Connection conn = getConnection("cases");
        Statement stat = conn.createStatement();
        stat.execute("CREATE TABLE TEST(ORDER_ID INT PRIMARY KEY, ORDER_DATE DATETIME, " +
                "USER_ID INT, DESCRIPTION VARCHAR, STATE VARCHAR, TRACKING_ID VARCHAR)");
        Timestamp orderDate = Timestamp.valueOf("2005-05-21 17:46:00");
        String sql = "insert into TEST (ORDER_ID,ORDER_DATE,USER_ID,DESCRIPTION,STATE,TRACKING_ID) " +
                "select cast(? as int),cast(? as date),cast(? as int),cast(? as varchar)," +
                "cast(? as varchar),cast(? as varchar) union all select ?,?,?,?,?,?";
        PreparedStatement ps = conn.prepareStatement(sql);
        ps.setInt(1, 5555);
View Full Code Here

        stat.execute("INSERT INTO TEST VALUES(1, '2001-01-01', '20:00:00', '2002-02-02 22:22:22.2')");
        ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
        rs.next();
        Date d1 = rs.getDate("D");
        Time t1 = rs.getTime("T");
        Timestamp ts1 = rs.getTimestamp("TS");
        rs.next();
        Date d2 = rs.getDate("D");
        Time t2 = rs.getTime("T");
        Timestamp ts2 = rs.getTimestamp("TS");
        assertTrue(ts1 != ts2);
        assertTrue(d1 != d2);
        assertTrue(t1 != t2);
        assertTrue(t2 != rs.getObject("T"));
        assertTrue(d2 != rs.getObject("D"));
View Full Code Here

        stat.execute("DROP TABLE TEST");
    }

    private void testDate(Connection conn) throws SQLException {
        PreparedStatement prep = conn.prepareStatement("SELECT ?");
        Timestamp ts = Timestamp.valueOf("2001-02-03 04:05:06");
        prep.setObject(1, new java.util.Date(ts.getTime()));
        ResultSet rs = prep.executeQuery();
        rs.next();
        Timestamp ts2 = rs.getTimestamp(1);
        assertEquals(ts.toString(), ts2.toString());
    }
View Full Code Here

        }
      }
      if(date == null){
        return null;
      }else if(clazz.equals(Timestamp.class)){
        return new Timestamp(date.getTime());
      }else if(clazz.equals(Calendar.class)){
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date.getTime());
        return cal;
      }else if(clazz.equals(java.sql.Date.class)){
View Full Code Here

        return lastModified;
    }

    public void setLastModified(long lastModified) {
        this.lastModified = lastModified;
        this.timestamp = new Timestamp(lastModified);
    }
View Full Code Here

        return f != null && f.exists() ? f.length() : 0;
    }

    public Timestamp getLastModified() {
        File f = getFile();
        return f != null && f.exists() ? new Timestamp(f.lastModified()) : null;
    }
View Full Code Here

        }
        testValue(ValueDate.get(new Date(System.currentTimeMillis())));
        testValue(ValueDate.get(new Date(0)));
        testValue(ValueTime.get(new Time(System.currentTimeMillis())));
        testValue(ValueTime.get(new Time(0)));
        testValue(ValueTimestamp.get(new Timestamp(System.currentTimeMillis())));
        testValue(ValueTimestamp.get(new Timestamp(0)));
        testValue(ValueJavaObject.getNoCopy(new byte[0]));
        testValue(ValueJavaObject.getNoCopy(new byte[100]));
        for (int i = 0; i < 300; i++) {
            testValue(ValueBytes.getNoCopy(new byte[i]));
        }
View Full Code Here

        assertEquals(6, getIsoDayOfWeek(parse("2008-10-04")));
        assertEquals(7, getIsoDayOfWeek(parse("2008-10-05")));
    }

    private static int getIsoWeek(Date date) {
        Timestamp ts = new Timestamp(date.getTime());
        return DateTimeUtils.getIsoWeek(ts);
    }
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.