NullPointerException when calling TimeZone.getAvailableIDs ()

I have tried many code examples where I generally do

String[] IDs = java.util.TimeZone.getAvailableIDs();

and it does not work. I also tried another sample code frame, i.e. this and it returns:

at sun.util.calendar.ZoneInfoFile.getZoneIDs(ZoneInfoFile.java:785)
at sun.util.calendar.ZoneInfo.getAvailableIDs(ZoneInfo.java:560)
at java.util.TimeZone.getAvailableIDs(TimeZone.java:508)
at TimeZoneDemo.main(uu.java:6)

I also tried reinstalling the JRE and JDK, but the error persists. So what's the point? When I try to execute String[] eg = {"one","two"};, it works.

+5
source share
2 answers

, Ubuntu 16.04

sudo apt-add-repository ppa:justinludwig/tzdata
sudo apt-get update
sudo apt-get install tzdata-java
+15

All Articles