日期:2014-05-20 浏览次数:20810 次
public class DateUtil {
public static Date parseYMDHMS(String ymdHMS) {
SimpleDateFormat dateFormate = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
try {
return dateFormate.parse(ymdHMS);
} catch (ParseException e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
System.out.println(DateUtil.parseYMDHMS("2012-02-01 18:00:00").toString());
}
}
DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("GMT-2"));//设置时区
Date date=df.parse("2013-02-01 00:00:00");
System.out.print(date);