For example: (a) Java language code
Converts a time input string tm= "1999-12-22" (time) to date (Java.sql.Date not java.util.Date)
And then in the DateTime-type Time field saved to SQL!
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd");
String aa= "1999-12-22";
Java.util.Date timedate = null;
try {
Timedate = Sdf.parse (AA);
catch (ParseException e) {
TODO automatically generate catch blocks
E.printstacktrace ();
}//util type
Java.sql.Date dateTime = new Java.sql.Date (Timedate.gettime ());//sql type
For example: (i) Oracle
can be converted using Oracle's to_date function,
or java.sql.Date (int year, int month, int day) , it is automatically corresponding to the date type of Oracle; For example:
String LSTR = "02-06-2003";
int Lday = Integer.parseint (lstr.substring (0,2));
int Lmon = Integer.parseint (lstr.substring (3,5));
int Lyear = Integer.parseint (lstr.substring (6));
Date ldate = new Date (lyear, Lmon, lday);