I have my strings like so in my strings.xml:
<string name="day_format">EEEE</string>
<string name="date_format">dd. MMMM</string>
<string name="date_format_us">MMMM dd</string>
And I use them like this in the code:
private void reinit() {
mDayFormat = getString(R.string.day_format);
if (!DateFormat.is24HourFormat(this))
{
mDateFormat = getString(R.string.date_format_us);
}
else {
mDateFormat = getString(R.string.date_format);
}
mTimeFormat = is24HourMode(this) ? FORMAT_24_HOURS : FORMAT_12_HOURS;
mCalendar = Calendar.getInstance();
}
But it displays the day and the month in lowercase, and I want it to capitalize both. How can I achieve that?
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.