Java?????????????????????????
???????????? ???????[ 2013/1/30 10:51:22 ] ????????
???????????????е?????????????????е???????????????????????????????ò?????????????????????????SQL??????ó????????????????????????????????????????
????????Java?е??????????????е?????????????????д??????????
/**
*
* @param utilDate
* @return
*/
public static java.sql.Date convertUtilDateToSqlDate(java.util.Date utilDate) {
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
return sqlDate;
}
/**
*
* @param sqlDate
* @return
*/
public static java.util.Date convertSqlDateToUtilDate(java.sql.Date sqlDate){
java.util.Date utilDate =new java.util.Date(sqlDate.getTime());
return utilDate;
}
??????????????????????????????????????????Щ???????
????1??????ó??????????????д??????????Date?????????
???????磺PreparedStatement.setDate(int ??java.sql.Date)???? ????????е?java.sql.Date????????????????????
???????磺TO_DATE(new SimpleDateFormat().format(ud??"yyyy-MM-dd HH:mm:ss")??"YYYY- MM-DD HH24:MI:SS")
???????????SQL?????д????SQL??“UPDATE TABLENAME SET TIMER = TO_DATE(" "+ TIMEMISS +" "?? ' yyyymmddhh24miss' ) WHERR ... ” ? TIMEMISS ????? ???磺20080522131223 ????
????2??????????????????????????????????java.sql.Date
??????????·???????????
???????????
public static java.sql.Date convertStringToSqlDate(String formatStr?? String timeStr) {
SimpleDateFormat bartDateFormat = new SimpleDateFormat(formatStr);
java.sql.Date sqlDate = null;
try {
java.util.Date date = bartDateFormat.parse(timeStr);
sqlDate = new java.sql.Date(date.getTime());
System.out.println(sqlDate.getTime());
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
return sqlDate;
}
????????????
String strDate = "2002-08-09";
StringTokenizer st = new StringTokenizer(strDate?? "-");
java.sql.Date date = new java.sql.Date(Integer.parseInt(st.nextToken()));
?????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11