问题
So, so far I have this:
static SimpleDateFormat df = new SimpleDateFormat("dd MM yyyy");
jDateChooser8 = new com.toedter.calendar.JDateChooser();
when I parse the right date let's say this one:
jDateChooser8.setDate(df.parse("24 07 1987"));
it's ok, but when I try to parse ""
(empty string)
jDateChooser8.setDate(df.parse(""));
I get an exeption:
first line of error is:
java.text.ParseException: Unparseable date: ""
all I want to do is set date to ""
, how to do it?
回答1:
The javadoc for parse states: "Throws: ParseException - if the beginning of the specified string cannot be parsed."
The string ""
cannot be parsed, and thus a ParseException
is thrown.
回答2:
i did what i want with seems it worked.
jDateChooser8.cleanup();
来源:https://stackoverflow.com/questions/28541698/parse-a-empty-string-into-simpledateformat