2008年9月7日 星期日

Date date = new Date();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");

String a = sdf.format(date.getTime());

date = sdf.parse(a);

Test t = new Test();

t.setStartDate(date);

Date enddate = new Date();

String end = sdf.format(date.getTime()+(60L*60L*24L*30L*1000));
enddate = sdf.parse(end);

t.setEndDate(enddate);

Session session = MulderSessionFactory.getSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate(t);
tx.commit();
MulderSessionFactory.closeSession();