SimpleDateFormat dd=new SimpleDateFormat("yyyymmdd"); Date xx=dd.parse("20080807");貌似如此
new SimpleDateFormat("格式").parse("20070807") 返回值是DATE类型的
/** * 字符串转换成日期 * @param str * @return date */ public static Date StrToDate(String str) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = null; try { date = format.parse(str); } catch (ParseException e) { e.printStackTrace(); } return date; }
DateFormat dFormat = new SimpleDateFormat("yyyyMMDD"); java.util.Date d = null; try { d = dFormat.parse("20080821"); } catch (ParseException e) { e.printStackTrace();// 解析出错 }
Date xx=dd.parse("20080807");貌似如此
返回值是DATE类型的
* 字符串转换成日期
* @param str
* @return date
*/
public static Date StrToDate(String str) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
java.util.Date d = null;
try {
d = dFormat.parse("20080821");
} catch (ParseException e) {
e.printStackTrace();// 解析出错
}
天数小写dd一般的全部格式是:yyyy-MM-dd HH:mm:ss
中间的格式符号可以不要或改动