一.String与Date(java.util.Date)互转 1.1 String -> Date Date date = DateFormat.parse(String str); String dateStr = "2010/05/04 12:34:23"; Date date = new Date(); //注意format的格式要与日期String的格式相匹配 DateFormat sdf = new SimpleDateFormat("yyyy/MM/d…
SimpleDateFormat函数语法: G 年代标志符 y 年 M 月 d 日 h 时 在上午或下午 (1~12) H 时 在一天中 (0~23) m 分 s 秒 S 毫秒 E 星期 D 一年中的第几天 F 一月中第几个星期几 w 一年中第几个星期 W 一月中第几个星期 a 上午 / 下午 标记符 k 时 在一天中 (1~24) K 时 在上午或下午 (0~11) z 时区 */ DateFormat format1 = new SimpleDate…
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 = "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…