数据库中对日期对象的转换

public class DateUtil
{
       private static SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
       private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

      public static String getDateTimeString(Date date)
 {
     if (date == null)
       return "";
     return datetimeFormat.format(date);
 }
  public static Date getDateTimeDate(String times) throws ParseException{
  
    if (times == null)
         return datetimeFormat.parse(times);
   return null;
 }
}

发布了37 篇原创文章 · 获赞 13 · 访问量 5万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章