This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Now here when I do System.out I get the following value //1305731118045
Here I am saving the above timestamp in Oracle table String query_2 = "insert into tsdate values(?)"; PreparedStatement prepstat = dbConnection.prepareStatement( query_2 ); prepstat.setTimestamp( 1, ts11 ); rows = prepstat.executeUpdate();
now when I check the data in oracle table it is saved as
5/18/2011 11:05:19.045000 AM
which is not correct as my original date is 2007 but here it's shown as 2011
And here I am reading it back again from the table:
String selQuery = "Select tsdate from tsdate"; Statement s = dbConnection.createStatement(); ResultSet rs = s.executeQuery(selQuery); java.sql.Timestamp ts22 = rs.getTimestamp("tsdate"); long tsTime1 = ts22.getTime(); System.out.println("Value is: "+tsTime1); //1305731118045 Calendar cal = Calendar.getInstance(); DateFormat d = DateFormat.getInstance(); SimpleDateFormat sdf2 = new SimpleDateFormat( "yyyymmddhhMMssSS" );