How to get DayOfWeek from an Instant.now()
问题 Assuming the following code... Instant x = Instant.now(); How do I get day of week from x? 回答1: You have to convert it to ZonedDateTime Instant.now().atZone(ZoneId.systemDefault()).getDayOfWeek() 回答2: I have awarded points to techtabu, but I ended up using atOffset instead. Here is where I ended up... int currentDayOfWeekValue = Instant.now().atOffset(ZoneOffset.UTC).getDayOfWeek().getValue(); I am amazed how difficult the Java8 datetime libraries are. There are so many variations of similar