Java 8 ZoneOffset - How to get current system UTC offset

Allison Burgers :

I want to get current ZoneOffset of my system.
I tried to do that but I couldn't find a way.
Also, I was looking for a solution but I didn't find any.
Is it possible to do that in Java?

EDIT:
My question is different to this. I would like to know the current system UTC, not how to convert between TimeZone offset representation or TimeZone storing.

Michał Szewczyk :

Yes, it's possible:

ZoneOffset.systemDefault().getRules().getOffset(Instant.now())

or you can replace Instant instance with LocalDateTime instance:

ZoneOffset.systemDefault().getRules().getOffset(LocalDateTime.now())

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=452274&siteId=1