标签:io ar java for sp 2014 on c r
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class date {
/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
String endDate=" 2014-09-10 ";
System.out.println(setString2SQLDate(endDate));
}
/** * 将某个日期字符串转换为java.sql.Date的类型 * @param dateStr 可为"yyyy-MM-dd HH:mm:ss"和"yyyy-MM-dd" * @return */
public static java.sql.Date setString2SQLDate(String dateStr){
SimpleDateFormat dateFormatHiddenHour = new SimpleDateFormat("yyyy-MM-dd");
java.sql.Date date = null;
try {
String s = dateFormatHiddenHour.format(dateFormatHiddenHour.parse(dateStr));
date = java.sql.Date.valueOf(s);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return date;
}
}
标签:io ar java for sp 2014 on c r
原文地址:http://www.cnblogs.com/JsonShare/p/3999612.html