时间格式化SimpleDateFormat
private Date formateTime (Date date)throws UnitedException{
if (date ==null){
return null;
}
Date dateResult =new Date();
try {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateResult = formatter.parse(formatter.format(date));
}catch (Exception e){
throw new UnitedException("时间格式化出错");
}
return dateResult;
}
时间格式化FastDateFormat
private String formateTime (Date date)throws UnitedException{
if (date ==null){
return null;
}
String dateResult = null;
try {
dateResult= FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss").format(date);
}catch (Exception e){
throw new UnitedException("时间格式化出错");
}
return dateResult;
}