my input is 19.12.0009, which expect Dec 19 00:00:00 HKT 9, but the return is Dec 21 00:23:18 HKT 9, why? the code is as follow:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.uuuu")
.withResolverStyle(ResolverStyle.STRICT);
LocalDate localDate = LocalDate.parse("19.12.0009", formatter);
Instant instant = Instant.from(localDate.atStartOfDay(ZoneId.of("Asia/Hong_Kong")));
Date resultDate = Date.from(instant);
System.out.println("resultDate" + resultDate);
In ZoneRules there is concept of transitions, which inside have
savingsLocalTransitions. I figured out that savings in"Asia/Hong_Kong"local transitions starts with1904-10-30T00:36:42for some reason (probably historic reasons).ResolverStyle.STRICTis no the issue here!This is the reason you see
00:23:18 HKT 9.If you change your code, for example like that:
output will be expected: