How can I get the day of week or month as a String? Without having to do something like:
DateTime now = DateTime.now();
String dayOfWeek = null;
switch(now.getDayOfWeek()) {
case DateTimeConstants.MONDAY:
dayOfWeek = "Monday";
break;
case DateTimeConstants.TUESDAY:
dayOfWeek = "Tuesday";
break;
case DateTimeConstants.WEDNESDAY:
dayOfWeek = "Wednesday";
break;
case DateTimeConstants.THURSDAY:
dayOfWeek = "Thursday";
break;
case DateTimeConstants.FRIDAY:
dayOfWeek = "Friday";
break;
case DateTimeConstants.SATURDAY:
dayOfWeek = "Saturday";
break;
case DateTimeConstants.SUNDAY:
dayOfWeek = "Sunday";
break;
}
Well, apparently it's just dateTime.dayOfWeek().getAsText();
as documented here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With