outWriter.print("{\"name\":\"" + l.toString() + "\",");
/*
* Month names (both short and full)
*/
final DateFormatSymbols dfs = new DateFormatSymbols(l);
final String[] short_months = dfs.getShortMonths();
final String[] months = dfs.getMonths();
outWriter.print("\"smn\":[\""
+ // ShortMonthNames
short_months[0] + "\",\"" + short_months[1] + "\",\""
+ short_months[2] + "\",\"" + short_months[3] + "\",\""
+ short_months[4] + "\",\"" + short_months[5] + "\",\""
+ short_months[6] + "\",\"" + short_months[7] + "\",\""
+ short_months[8] + "\",\"" + short_months[9] + "\",\""
+ short_months[10] + "\",\"" + short_months[11] + "\""
+ "],");
outWriter.print("\"mn\":[\""
+ // MonthNames
months[0] + "\",\"" + months[1] + "\",\"" + months[2]
+ "\",\"" + months[3] + "\",\"" + months[4] + "\",\""
+ months[5] + "\",\"" + months[6] + "\",\"" + months[7]
+ "\",\"" + months[8] + "\",\"" + months[9] + "\",\""
+ months[10] + "\",\"" + months[11] + "\"" + "],");
/*
* Weekday names (both short and full)
*/
final String[] short_days = dfs.getShortWeekdays();
final String[] days = dfs.getWeekdays();
outWriter.print("\"sdn\":[\""
+ // ShortDayNames
short_days[1] + "\",\"" + short_days[2] + "\",\""
+ short_days[3] + "\",\"" + short_days[4] + "\",\""
+ short_days[5] + "\",\"" + short_days[6] + "\",\""
+ short_days[7] + "\"" + "],");
outWriter.print("\"dn\":[\""
+ // DayNames
days[1] + "\",\"" + days[2] + "\",\"" + days[3] + "\",\""
+ days[4] + "\",\"" + days[5] + "\",\"" + days[6] + "\",\""
+ days[7] + "\"" + "],");
/*
* First day of week (0 = sunday, 1 = monday)
*/
final Calendar cal = new GregorianCalendar(l);
outWriter.print("\"fdow\":" + (cal.getFirstDayOfWeek() - 1) + ",");
/*
* Date formatting (MM/DD/YYYY etc.)
*/
DateFormat dateFormat = DateFormat.getDateTimeInstance(
DateFormat.SHORT, DateFormat.SHORT, l);
if (!(dateFormat instanceof SimpleDateFormat)) {
System.err
.println("Unable to get default date pattern for locale "
+ l.toString());
dateFormat = new SimpleDateFormat();
}
final String df = ((SimpleDateFormat) dateFormat).toPattern();
int timeStart = df.indexOf("H");
if (timeStart < 0) {
timeStart = df.indexOf("h");
}
final int ampm_first = df.indexOf("a");
// E.g. in Korean locale AM/PM is before h:mm
// TODO should take that into consideration on client-side as well,
// now always h:mm a
if (ampm_first > 0 && ampm_first < timeStart) {
timeStart = ampm_first;
}
// Hebrew locale has time before the date
final boolean timeFirst = timeStart == 0;
String dateformat;
if (timeFirst) {
int dateStart = df.indexOf(' ');
if (ampm_first > dateStart) {
dateStart = df.indexOf(' ', ampm_first);
}
dateformat = df.substring(dateStart + 1);
} else {
dateformat = df.substring(0, timeStart - 1);
}
outWriter.print("\"df\":\"" + dateformat.trim() + "\",");
/*
* Time formatting (24 or 12 hour clock and AM/PM suffixes)
*/
final String timeformat = df.substring(timeStart, df.length());
/*
* Doesn't return second or milliseconds.
*
* We use timeformat to determine 12/24-hour clock
*/
final boolean twelve_hour_clock = timeformat.indexOf("a") > -1;
// TODO there are other possibilities as well, like 'h' in french
// (ignore them, too complicated)
final String hour_min_delimiter = timeformat.indexOf(".") > -1 ? "."
: ":";
// outWriter.print("\"tf\":\"" + timeformat + "\",");
outWriter.print("\"thc\":" + twelve_hour_clock + ",");
outWriter.print("\"hmd\":\"" + hour_min_delimiter + "\"");
if (twelve_hour_clock) {
final String[] ampm = dfs.getAmPmStrings();
outWriter.print(",\"ampm\":[\"" + ampm[0] + "\",\"" + ampm[1]
+ "\"]");
}
outWriter.print("}");
if (pendingLocalesIndex < locales.size() - 1) {