Bug in DateTimeFormatter?

val date_formatter = java.time.format.DateTimeFormatter.ofPattern(“YYYYMMdd”)

tmp = (new DateTimeType).getZonedDateTime(ZoneId.systemDefault()).minusMinutes(2).format(date_formatter)

shows since today wrong year.

Yesterday output had been 20251228

Today output is 20261229

Date and timezone, everything is correct.

I have no idea why year is already next one.

Crazy: If i change to

val date_formatter = java.time.format.DateTimeFormatter.ofPattern(“YYYYMMdd”)

tmp = (new DateTimeType).getZonedDateTime(ZoneId.systemDefault()).minusMinutes(2).minusYears(1).format(date_formatter)

it shows 20241229.

So no way to get exact string 20251229

O.K., found it.

A shame for me, but may help others:

YYYY means Year of week (and since today its week 1)

yyyy means year from date results in correct 2025:

val date_formatter = java.time.format.DateTimeFormatter.ofPattern(“yyyyMMdd”)

solves it