Java Data Type How to - Get all zone id strings








Question

We would like to know how to get all zone id strings.

Answer

import java.time.ZoneId;
// ww  w.  ja va 2 s  . co m
public class Main {

  public static void main(String[] args) {
    ZoneId.getAvailableZoneIds().stream().filter(s -> s.startsWith("Asia"))
        .forEach(System.out::println);

    ZoneId.getAvailableZoneIds().stream().forEach(System.out::println);

  }
}

The code above generates the following result.