Java 中日期格式转换 /** * 字符串转换为java
Date * 支持格式为 yyyy
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
dd G 'at' hh:mm:ss z"); if(tempPos>-1){ time=time
substring(0,tempPos)+ "公元"+time
substring(tempPos+"AD"
length());//china formatter = new SimpleDateFormat ("yyyy
dd G 'at' hh:mm:ss z"); } tempPos=time
indexOf("-"