import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
//要转化的字符串
String end = "2013-04-22 5:7:0";
//日期的格式
DateFormat myFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//将字符串转化为日期类型
Date endDate = myFormat.parse(end);
//将日期转化为Sting类型
String theFinalDate = myFormat.format(endDate);
//输出转化结果
System.out.println(theFinalDate);
Java 年月日时分秒日期格式