I have written the following function in Java. This function returns current timestamp by executing a query. The function code is as follows :
private String getTimeStamp(){
String timeStamp=null;
try{
String strQuery="select current_timestamp";
PreparedStatement pmtQuery=con.prepareStatement(strQuery);
ResultSet rsQuery=pmtQuery.executeQuery();
rsQuery.next();
timeStamp=rsQuery.getString(1);
JOptionPane.showMessageDialog(null, "Value of timeStamp : "+timeStamp);
}catch(SQLException e){
System.out.println("SQL Exception in the getTimeStamp()");
}
return timeStamp;
}
When I use this function on windows It gives proper out put and works fine.
Ex.
If execute above function in widows it gives timestamp like ex. 2011-06-01 17:05:03
but when I execute this function in Debina linux it gives timestamp as
2011-06-01 17:05:03.0
It appends .0 to timestamp
Please guide me in this problem
1.why such different output comes on different system? 2.How to avoid this problem? 3.How to solve this problem?
I am using following configurations
windows
windows 7, Mysql database, Java 6
Linux
Debian linux, Mysql Database, Java 6
Thank You!
Use this
Note:
I wonder why you are querying to get the currentDate