2 ms·
calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US) I guess. Not that it's necessarily nicer, but generally I'd say duplicating functional
by ygra 13y ago
calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US)
I guess.
Not that it's necessarily nicer, but generally I'd say duplicating functionality of the standard libraries or frameworks should be avoided if possible.
- msluyter 13y agoWell, this gets you the day of the week for whatever the current time is. The example in the article didn't do that exactly. It took a string of some sort (in what format, exactly, isn't clear to me) and mapped it to another string. Assuming that the input string is a formatted date of some sort, then I think this would work, using JodaTime (minus exception handling): public String getDayOfWeek(String s) { DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy"); DateTime dt = formatter.parseDateTime(s); return dt.dayOfWeek().getAsText(); }