Sql DateTime : Database Type vs Java Type « Database SQL JDBC « Java






Sql DateTime

 

public class SqlDateTime {

  public static void main(String[] args) {
    java.util.Date javaDate = new java.util.Date();
    long javaTime = javaDate.getTime();
    System.out.println("The Java Date is: " + javaDate.toString());

    java.sql.Date sqlDate = new java.sql.Date(javaTime);
    System.out.println("The SQL DATE is: " + sqlDate.toString());

    java.sql.Time sqlTime = new java.sql.Time(javaTime);
    System.out.println("The SQL TIME is: " + sqlTime.toString());

    java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(javaTime);
    System.out.println("The SQL TIMESTAMP is: " + sqlTimestamp.toString());
  }
}

 








Related examples in the same category

1.Standard SQL Data Types with Their Java Equivalents
2.Get Available Table Types
3.All data types for Oracle
4.Create Table With All Data Types In MySQL
5.Get Available Sql Types In A Database