如何以字符串形式获取星期几或月份?无需执行以下操作:
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;
}