gpt4 book ai didi

java - 获取 DateTime dayOfWeek/dayOfMonth 作为字符串

转载 作者:搜寻专家 更新时间:2023-10-31 08:20:24 25 4
gpt4 key购买 nike

如何获取星期几或月份的日期作为字符串?无需执行以下操作:

        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;
}

最佳答案

好吧,显然它只是 dateTime.dayOfWeek().getAsText(); 记录的 here .

关于java - 获取 DateTime dayOfWeek/dayOfMonth 作为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14044324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com