1.String ->Date String StrDate = "2012-12-12"; SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); date=sdf.parse(StrDate); 2.Date ->String String StrDate = ""; Date date = new…
一.String与Date(java.util.Date)互转 1.1 String -> Date String dateStr = "2010/05/04 12:34:23"; Date date = new Date(); //注意format的格式要与日期String的格式相匹配 DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); try { date = sdf.parse(da…
一.String与Date(java.util.Date)互转 1.1 String -> Date String dateStr = "2016-9-28 12:25:55"; Date date = new Date(); //注意format的格式要与日期String的格式相匹配 DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); try { date = sdf.parse(dat…