I wrote the following code to parse a simple date like "09-MAR-17":
DateFormat df = new SimpleDateFormat("dd-MMM-yy");
Date start = null;
Date end = null;
try {
start = df.parse(data.get(i)[Columns.PACKAGESTART.ordinal()]);
end = df.parse(data.get(i)[Columns.PACKAGEEND.ordinal()]);
} catch (ParseException ex) {
ex.printStackTrace();
}
However this throws the following exception:
java.text.ParseException: Unparseable date: "07-MAR-17"
at java.text.DateFormat.parse(DateFormat.java:357)
However i dont know why. Is "dd-MMM-yy" an incorrect format?
EDIT: running this in netbeans gives me an exception, running the exact same code in eclipse seems to work.
I experimented with this a bit and found that the parsing is locale-dependent. For instance, "07-MAY-17" will work with an English locale but not a Swedish one (where the month of May is named "maj"). I would suspect something similar is happening for you.