title: parsing timestamp from mysql to csv using java
body: <p>i have a mysql db, and i have one table which has many columns including a timestamp one. i want to read the table and write it to a csv file. then i will read from the csv file the data and insert it in another db and table. all these are done through java.
  I can read the table date and the timestamp from the first db, but the timestap is not written correctly into the csv file.. only the last few digits are written. for example if i have a timestamp 2012-11-01 02:18:00.0 only the 18:00.0 will be written to the csv. All the other stuff work fine. For example if i hard write a timestamp i can write it to the second db. there;s the code for reading mysql and writing to csv :</p>
  
  <pre><code>                    con = DriverManager.getConnection("jdbc:mysql://localhost/campdb", "...", "...");
  
                      stmt = (Statement) con.createStatement();
                      fw = new FileWriter(filename);
                      PrintWriter a = new PrintWriter(fw);
                      ResultSet res = stmt.executeQuery("SELECT * FROM CAMPREQ;");
                      while (res.next()) 
                      {
                          String ID = res.getString(1);
                          java.sql.Date date = res.getDate(2);
                          //java.util.Date jdate = new java.util.Date(date.getTime());
                          String company = res.getString(3);
                          String time = res.getString(4);
                          String origin = res.getString(5);
                          String dest = res.getString(6);
                          String timestamp = res.getString(7);
                          System.out.println(timestamp);
                          a.print(ID);
                          a.print(',');
                          a.print(date);
                          a.print(',');
                          a.print(company);
                          a.print(',');
                          a.print(time);
                          a.print(',');
                          a.print(origin);
                          a.print(',');
                          a.print(dest);
                          a.print(',');
                          a.print(timestamp);
                          a.print('\n');
                          a.flush();
  
                      }
  </code></pre>
  
  <p>The System.out command prints the timestamp as it should be written, however it is not written correctly in the csv :(
  thank you</p>