import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * String 转Date */ public static Date stringToDate(String str){ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date time =null; try { time=sdf.parse(str); } catch (ParseException e) { e.printStackTrace(); } return time; } /** * Date 转String */ public static String dateToString(Date date){ SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String str =sdf.format(date); return str; }
本文出自 “猴子也疯狂” 博客,请务必保留此出处http://1251769215.blog.51cto.com/11633863/1786988
原文地址:http://1251769215.blog.51cto.com/11633863/1786988