string 转换成date
String date="2014-06-26 10:09:22.819"; SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS"); Date lastupdated = sdf.parse(date);
date转换成string
private String changedtos(Date date) { // TODO Auto-generated method stub SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); String ss = sdf.format(date); System.out.println(ss); return ss; }
jda数据库时间比较
// date以降のmessage try { Query query = em .createQuery( "select e from MessageEntity e where e.groupId = :groupId AND :date < e.date" + " order by e.date asc", MessageEntity.class); query.setParameter("groupId", groupId); query.setParameter("date", date); return query.getResultList(); } finally { em.close(); }