我有一段程序,想把数据库中的一个字段date_due里的内容加上某个天数,然后写回数据库,我用的是
java.util.Calendar aa = java.util.Calendar.getInstance();
aa.setTime(date_due);
aa.add(Calendar.DAY_OF_MONTH,10);
aa.getTime();
但是我怎么把结果写到数据库里和aa.getTime()的返回值是什么类型?string ?
java.util.Calendar aa = java.util.Calendar.getInstance();
aa.setTime(date_due);
aa.add(Calendar.DAY_OF_MONTH,10);
aa.getTime();
但是我怎么把结果写到数据库里和aa.getTime()的返回值是什么类型?string ?
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIME.
static int TIMESTAMP
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIMESTAMP.
Calendar:
getTime
public final Date getTime()
Gets this Calendar's current time. Returns:
the current time.
java.util.Calendar aa = java.util.Calendar.getInstance();
aa.setTime(date_due);
aa.add(Calendar.DATE,30);
Date date = aa.getTime();
java.sql.Date temp=null;
temp.setTime(date.getTime());
date_due.setTime(date_due.getTime() + 10 * 24 * 3600 * 1000);//10天换算成毫秒数
//现在可以把date_due再送回数据库了