title: How to use SQL Server datetime type in Java
body: <p>I'm using Microsoft SQL Server 2008 R2, Java 7 and Microsoft JDBC Driver 4.0 for SQL Server.</p>
  
  <p>Once I have a ResultSet named rs what's the simplest method to get a "Date and Time" type from a datetime column from which I can extract day, month, year, hour, minute and second?</p>
  
  <p>With other types I can simply use rs.getString("column name") rs.getInt("column name") etc. methods but getDate return a Date type and getHour() etc. are marked as deprecated in documentation.</p>