Date format
i don't understand why this will format all my dates except the month of sept... any suggestions?
Format df =new SimpleDateFormat(" MMMM dd yyyy hh:mm a");
DateFormat df2 = DateFormat.getDateInstance(DateFormat.MEDIUM);
Date d1 = df.parse(editrow[first][0]);
newDate = df2.format(d1);
i use July 31 2007 10:00 AM....Aug 14 2007 9:00 PM......Oct 26 2007 9:00 PM ...ect but it errors on Sept 15 2007 7:00 AM
[502 byte] By [
mark07a] at [2007-11-27 11:56:58]

import java.text.*;
import java.util.*;
public class FormatExample {
public static void main(String[] args) throws ParseException {
DateFormatSymbols symbols = DateFormatSymbols.getInstance(); //1.6
String[] months = symbols.getShortMonths();
System.out.println(Arrays.toString(months));
months[8]="Sept";
symbols.setShortMonths(months);
String[] data = {
"July 31 2007 10:00 AM",
"Aug 14 2007 9:00 PM",
"Oct 26 2007 9:00 PM",
"Sept 15 2007 7:00 AM"
};
DateFormat df = new SimpleDateFormat("MMMM dd yyyy hh:mm a", symbols);
DateFormat df2 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM);
for(String s : data) {
Date d = df.parse(s);
System.out.format("%s --> %s%n", s, df2.format(d));
}
}
}
I looked in the sourcecode of SimpleDateFormat
if the placeholder for Month is MMM or MMMM they try to match first the full monthname and then the short form (3 letter only), thats why Juli and Aug worked, but Sept not.
Franco