如何将这个11/03/2009-20:06:16转换为Date对象,以便我可以比较两个日期。我不断收到java.lang.IllegalArgumentException异常:如果我用下面的实施无法格式化给定的对象作为一个日期的错误。我需要的输出为Date对象格式星期二7月14日1时32分31秒2009年将字符串日期转换为日期对象
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Dateaf {
/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
// TODO Auto-generated method stub
String text = "11/03/2009-20:06:16";
SimpleDateFormat dateParser = new SimpleDateFormat("MM/dd/yyyy-hh:mm:ss");
Date date = dateParser.parse(text);
System.out.println(date);
}
}
http://stackoverflow.com/questions/1543481/how-to- convert-string-object-to-date-object – Madara