I have my strings like so in my strings.xml:
EEEE
dd. MMMM
I fixed it like so:
final CharSequence date = DateFormat.format(mDateFormat, mCalendar);
final CharSequence day = DateFormat.format(mDayFormat, mCalendar);
String time = (String) DateFormat.format(mTimeFormat, mCalendar);
RemoteViews views = new RemoteViews(getPackageName(), R.layout.clock2by2);
String days = new String(day.toString().substring(0,1).toUpperCase() + day.toString().substring(1));
String dates = new String(date.toString().substring(0,1).toUpperCase() + date.toString().substring(1));
views.setTextViewText(R.id.Day, days);
views.setTextViewText(R.id.Date, dates);
views.setImageViewBitmap(R.id.TimeView, buildUpdate(time));
String's toUpperCase()
?
There are more precise way of doing this. You can control each part of your formatter using DateFormatSymbols.
Look at that, this is beautiful:
Scanner s = new Scanner(System.in);
SimpleDateFormat simpleDateFormatFrom = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormatTo = new SimpleDateFormat("MMM dd, yyyy");
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols();
String[] months = simpleDateFormatTo.getDateFormatSymbols().getShortMonths();
for (int i = 0; i < months.length; i++) {
months[i] = months[i].toUpperCase();
}
dateFormatSymbols.setShortMonths(months);
simpleDateFormatTo.setDateFormatSymbols(dateFormatSymbols);
Date date = simpleDateFormatFrom.parse(s.next());
System.out.println(simpleDateFormatTo.format(date));
You can use WordUtils.capitalize(..) from commons-lang (on the result string)
(this is in case you want to capitalize - i.e. uppercase only the first letter. Otherwise you can simpyl use .toUpperCase()
)
Update: Since it appears this is android, you can open the sources of WordUtils
and copy the implementation from there, rather than getting the whole library.