日期:2014-05-20 浏览次数:20805 次
DateFormat format = new SimpleDateFormat("yyyy MM dd hh:mm:ss");
format.setLenient(false);
String s = "2013.05.08 13:30:15";
Timestamp ts = new Timestamp(format.parse(s).getTime());
System.out.println(ts.toString());
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); //这里修改了
format.setLenient(false);
String s = "2013.05.08 13:30:15";
Timestamp ts = new Timestamp(format.parse(s).getTime());
System.out.println(ts.toString());
String s = "2013.05.08 13:30:15";
DateFormat format = new SimpleDateFormat("yyyy.MM.dd hh:mm:ss");
Date date = null;
try {
date = format.parse(s);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(date.toString());
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
format.setLenient(false);
String s = "2013.05.08 13:30:15";
Timestamp ts = new Timestamp(format.parse(s).getTime());
System.out.println(ts.toString());
DateFormat format = new SimpleDateFormat("yyyy.MM.dd hh:mm:ss");
format.setLenient(false);
String s = "2013.05.08 01:30:15";
Timestamp ts = new Timestamp(format.parse(s).getTime());
System.out.println(ts.toString());