日期:2014-05-20 浏览次数:20693 次
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class UTest3 {
public static void main(String args[]) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.setLenient(false);
try {
Date date = sdf.parse("19000101080000");
System.out.println(date);
} catch (ParseException e) {
System.out.println("Error");
}
}
}
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
public class UTest3 {
public static void main(String args[]) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.setLenient(false);
try {
GregorianCalendar calendar = new GregorianCalendar();
sdf.setCalendar(calendar);
Date date = sdf.parse("19000101080000");
System.out.println(date.toLocaleString());
} catch (ParseException e) {
e.printStackTrace();
System.out.println(e.getLocalizedMessage());
}
}
}