首页 > 其他 > 详细

Date类型转String 与 String转Date类型

时间:2015-11-03 21:09:59      阅读:295      评论:0      收藏:0      [点我收藏+]
  1. package com.ttgbook.conver;  
  2.   
  3. import java.text.DateFormat;  
  4. import java.text.SimpleDateFormat;  
  5. import java.util.Date;  
  6.   
  7. public class Conver {  
  8.       
  9.     //把日期转为字符串  
  10.     public static String ConverToString(Date date)  
  11.     {  
  12.         DateFormat df = new SimpleDateFormat("yyyy-MM-dd");  
  13.           
  14.         return df.format(date);  
  15.     }  
  16.     //把字符串转为日期  
  17.     public static Date ConverToDate(String strDate) throws Exception  
  18.     {  
  19.         DateFormat df = new SimpleDateFormat("yyyy-MM-dd");  
  20.         return df.parse(strDate);  
  21.     }  
  22.        

Date类型转String 与 String转Date类型

原文:http://www.cnblogs.com/xidada/p/4934254.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!