SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
yyyy-MM-dd HH:mm:ss 显示的格式是24小时
yyyy-MM-dd hh:mm:ss 显示的格式是12小时
//以下不是 - - 个人项目实例
for (Iterator iterator = lt.iterator(); iterator.hasNext(); ) {
Object[] hangs = (Object[]) iterator.next();
SmEventEmergencyList AnJianList =new SmEventEmergencyList();
AnJianList.setEmergencyId((String)hangs[0]);
AnJianList.setEnterpriseName((String)hangs[1]);
//AnJianList.setEmergencyDate((String)hangs[2]);
//判断数据库中日期是不是是为空,如果空则要转化
if(hangs[2]!=null){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date entertime =(Date)hangs[2];
String time = format.format(entertime);
AnJianList.setEmergencyDate(time);
}
AnJianList.setEmergencyCause((String)hangs[3]);
AnJianList.setSourceName((String)hangs[4]);
AnJianList.setEmergencyAdress((String)hangs[5]);
AnJianList.setSourceId((String)hangs[6]);
AnJianList.setLevelId((String)hangs[7]);
AnJianList.setEnterpriseId((String)hangs[8]);
ls.add(AnJianList);
}