I'm trying to format the current date with DateTimeFormatter and I almost get what I need, but my problem seems to be that days of the week are enumerated from Sunday, instead of Monday. So, for example, if I run below code on Tuesday
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter;
final LocalDateTime currentTime = LocalDateTime.now()
def DATE = currentTime.format(DateTimeFormatter.ofPattern("YYYY'cw'w'd'e"))
I'd expect the output: 2020cw10d2
, but the actual output I get is 2020cw10d3
. There's a localized day of week
pattern in
DateTimeFormatter documentation, which is e/c
option, however, it doesn't seem to change anything in my case. I'm located in Europe (GMT+1) and weeks are enumerated from Monday. Servers I work with are also located in the same timezone, but still, I get the same output on my desktop and my servers. What am I doing wrong? Is there a way to enumerate weeks from Monday in DateTimeFormatter?