/** * 时间格式化函数,默认为yyyy-MM-dd HH:mm:ss *<b>Summary: </b> * formatDate() * @param date * @param formate * @return */ public static String formatDate(Date date,String formate){ SimpleDateFormat sdf = null; if(date == null){ return ""; } if(formate == null || "".equals(formate.trim())){ sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } else { sdf = new SimpleDateFormat(formate); } String result = sdf.format(date); return result; } /** * 时间格式化函数,格式化为yyyy-MM-dd HH:mm:ss *<b>Summary: </b> * formatDate() * @param date * @return */ public static String formatDate(Date date){ return formatDate(date); }
StringUtil工具类 之 时间格式化函数,布布扣,bubuko.com
原文地址:http://blog.csdn.net/liu22985342/article/details/28606275