Date转换为各种String

  1. //把日期转为字符串  
  2.     public static String ConverToString(Date date)  
  3.     {  
  4.         DateFormat df = new SimpleDateFormat("yyyy-MM-dd");  
  5.           
  6.         return df.format(date);  
  7.     }  
  8.     //把字符串转为日期  
  9.     public static Date ConverToDate(String strDate) throws Exception  
  10.     {  
  11.         DateFormat df = new SimpleDateFormat("yyyy-MM-dd");  
  12.         return df.parse(strDate);  
  13.     }  

posted @ 2015-03-01 20:07  plmmlp09  阅读(303)  评论(0)    收藏  举报