title: getDate from mysql
body: <p>How can I convert a date from a mysql database to variable in Java?  This is what I have tried so far:</p>
  
  <pre><code>try {
      Connection connection = DriverManager.getConnection(database, user, pass);
      Statement statement = connection.createStatement();
      String sql = "select mhs.angkatan from t_nilai nilai JOIN t_mahasiswa mhs ON nilai.nim = mhs.nim WHERE mhs.nim = '" + txt_nim + "'";
      ResultSet resultSet = statement.executeQuery(sql);
      Date angkatan = resultSet.getDate("angkatan");
      resultSet.close();
      statement.close();
      connection.close();
  } catch (Exception e) {
      System.err.println(e.getMessage());
      JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.INFORMATION_MESSAGE);
      System.exit(0);
  }
  </code></pre>