I am trying to format the date like this:
Monday 4, November, 2013
This is my code:
private static String formatDate(Date date) { Calendar calenDate = Calendar.getInstance(); calenDate.setTime(date); Calendar today = Calendar.getInstance(); if (calenDate.get(Calendar.DAY_OF_MONTH) == today.get(Calendar.DAY_OF_MONTH)) { return "Today"; } today.roll(Calendar.DAY_OF_MONTH, -1); if (calenDate.get(Calendar.DAY_OF_MONTH) == today.get(Calendar.DAY_OF_MONTH)) { return "Yesterday"; }
But I do not want to use any split method or do something like that. Is there any pattern that I can include in the regular expression so that it is capitalized at the beginning of each word?
UPDATE I am from a Spanish-speaking country, something like new Locale("es", "ES") I get "martes 7, noviembre, 2013" when I need "Martes 7, Noviembre, 2013".
source share