Java中日期格式转换
java日期格式大全 format SimpleDateFormat Java中日期格式转换 /** * 字符串转换为java.util.Date * 支持格式为 yyyy.MM.dd G 'at' hh:mm:ss z 如 '2002-1-1 AD at 22:10:59 PSD' * yy/MM/dd HH:mm:ss 如 '2002/1/1 17:55:00' * yy/MM/dd HH:mm:ss pm 如 '2002/1/1 17:55:00 pm' * yy-MM-dd HH:mm:ss 如 '2002-1-1 17:55:00' * yy-MM-dd HH:mm:ss am 如 '2002-1-1 17:55:00 am' * @param time String 字符串 * @return Date 日期 */ public static Date stringToDate(String time){ SimpleDateFormat formatter; int tempPos=time.indexOf("AD") ; time=time.trim() ; formatter = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss z"); if(tempPos>-1){ time=time.substring(0