Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by NavBot

...

Code Block
bgColor#FFcccc
private Boolean validateValue(long time) {
  // Perform validation
  return true; // If the time is valid	
}

private void storeDateinDB(java.util.Date date) throws SQLException {
  final java.util.Date copy = (java.util.Date)date.clone();
  validateValue(copy.getTime());

  Connection con = DriverManager.getConnection(&quot;"jdbc:microsoft:sqlserver://&lt;HOST&gt;<HOST>:1433&quot;,&quot;&lt;UID&gt;&quot;,&quot;&lt;PWD&gt;&quot;","<UID>","<PWD>");

  PreparedStatement pstmt = con.prepareStatement(&quot;"UPDATE ACCESSDB SET TIME = ?&quot;");
  pstmt.setLong(1, copy.getTime());
  // ...
}	

...

Code Block
bgColor#ccccff
private void storeDateinDB(java.util.Date date) throws SQLException {
  final java.util.Date copy = new java.util.Date();
  validateValue(copy.getTime());

  Connection con = DriverManager.getConnection(&quot;"jdbc:microsoft:sqlserver://&lt;HOST&gt;<HOST>:1433&quot;,&quot;&lt;UID&gt;&quot;,&quot;&lt;PWD&gt;&quot;","<UID>","<PWD>");

  PreparedStatement pstmt = con.prepareStatement(&quot;"UPDATE ACCESSDB SET TIME = ?&quot;");
  pstmt.setLong(1, copy.getTime());
  // ...
}	

...

Wiki Markup
\[[Sterbenz 06|AA. Java References#Sterbenz 06]\] 

...

MET37MET38-J. Do not call overridable methods from a privileged block&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;invoke overridable methods on the clone under construction      12. Methods (MET)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MET35-J. Ensure that the clone method calls super.clone      13. Exceptional Behavior (EXC)