* @param ctx calling context, to get user's current date format * @param twoLines If true, format includes \n between day of week and short date. * @return a StringBuffer usable in DateFormat.format */ public static StringBuffer buildDateFormatDOWShort(Context ctx, final boolean twoLines) { // note use of android.text.format.DateFormat, // not java.text.DateFormat, throughout. StringBuffer fmt_dow_shortdate = new StringBuffer(); final char da = DateFormat.DAY; final char qu = DateFormat.QUOTE; fmt_dow_shortdate.append(da); fmt_dow_shortdate.append(da); fmt_dow_shortdate.append(da); fmt_dow_shortdate.append(da); fmt_dow_shortdate.append(qu); if (twoLines) fmt_dow_shortdate.append('\n'); else fmt_dow_shortdate.append(' '); fmt_dow_shortdate.append(qu); // year-month-date will be 3 chars: yMd, Mdy, etc final char[] ymd_order = DateFormat.getDateFormatOrder(ctx); for (char c : ymd_order) { fmt_dow_shortdate.append(c); fmt_dow_shortdate.append(c); if (c == DateFormat.YEAR) { fmt_dow_shortdate.append(c); fmt_dow_shortdate.append(c); } if (c != ymd_order[2]) fmt_dow_shortdate.append("/"); } return fmt_dow_shortdate; } }