简体   繁体   中英

How to determine if java's user.timezone was altered by the user?

I'm currently looking for a creative way how to find out if the user.timezone in java was altered by command line arguments or some other custom configuration. So technically I'm looking for a solution how to determine the real timezone of a computer (if this is even possible).

Any help is highly appreciated.

Thanks,

Perhaps you could determine it based on their ip and something like GeoLite2 . GeoLite2 can get the city and from you could look up that city's timezone (it might even give you the timezone directly, i'm not sure). You can get their ip at ipinfo .

The first solution that pops into my mind is probing external sources. eg if you type

wmic timezone get StandardName

in a Windows command line you should get your timezone. Theoretically you could get the output by running this command in Java, as described in this thread .

PS It's probably not 'high-quality' to run an obscure command in Java and it's probably not the most efficient thing either. The idea is to somehow use another process that doesn't inherit JVM arguments or other 'customizations' (eg command line, Javascript, possibly other script languages, etc.)


Another possibility would be (depending on what client info you have available) to use Google's Time Zone API .

eg https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM