Example usage for java.time ZoneId getAvailableZoneIds

List of usage examples for java.time ZoneId getAvailableZoneIds

Introduction

In this page you can find the example usage for java.time ZoneId getAvailableZoneIds.

Prototype

public static Set<String> getAvailableZoneIds() 

Source Link

Document

Gets the set of available zone IDs.

Usage

From source file:Main.java

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);

}

From source file:Main.java

public static void main(String[] args) {
    Set<String> zoneIds = ZoneId.getAvailableZoneIds();
    for (String zoneId : zoneIds) {
        System.out.println(zoneId);
    }/*from w w  w  .  j  av a2s. com*/
}

From source file:Main.java

public static void main(String[] args) {
    Set<String> allZones = ZoneId.getAvailableZoneIds();
    List<String> zoneList = new ArrayList<String>(allZones);
    Collections.sort(zoneList);// w w  w  . j  a  va 2  s  . c  om

    LocalDateTime dt = LocalDateTime.now();
    for (String s : zoneList) {
        ZoneId zone = ZoneId.of(s);
        ZonedDateTime zdt = dt.atZone(zone);
        ZoneOffset offset = zdt.getOffset();
        String out = String.format("%35s %10s%n", zone, offset);
        System.out.println(out);
    }
}

From source file:de.rkl.tools.tzconv.model.ApplicationModel.java

private static SetMultimap<ZoneOffset, ZoneId> sortAvailableZoneIds() {
    final SortedSetMultimap<ZoneOffset, ZoneId> zoneIdMap = TreeMultimap.create(Ordering.natural().reverse(),
            new Ordering<ZoneId>() {
                @Override//  ww  w.  java  2  s.com
                public int compare(final ZoneId zoneId1, final ZoneId zoneId2) {
                    return ComparisonChain.start().compare(zoneId1.toString(), zoneId2.toString()).result();
                }
            }.nullsFirst());
    ZoneId.getAvailableZoneIds().stream().forEach(zoneId -> {
        final ZoneId zoneIdObject = ZoneId.of(zoneId);
        zoneIdMap.put(zoneIdObject.getRules().getStandardOffset(Instant.now()), zoneIdObject);
    });
    return ImmutableSetMultimap.copyOf(zoneIdMap);
}

From source file:org.apache.metron.parsers.snort.BasicSnortParser.java

private DateTimeFormatter getDateFormatterWithZone(DateTimeFormatter formatter,
        Map<String, Object> parserConfig) {
    String timezone = (String) parserConfig.get("timeZone");
    if (StringUtils.isNotEmpty(timezone)) {
        if (ZoneId.getAvailableZoneIds().contains(timezone)) {
            _LOG.info("Using timezone '{}'", timezone);
            return formatter.withZone(ZoneId.of(timezone));
        } else {/*from   w  w w  . jav a  2s  . co m*/
            throw new IllegalArgumentException("Unable to find ZoneId '" + timezone + "'");
        }
    } else {
        _LOG.info("Using default timezone '{}'", ZoneId.systemDefault());
        return formatter.withZone(ZoneId.systemDefault());
    }
}

From source file:org.nodatime.tzvalidate.Java8Dump.java

@Override
public Iterable<String> getZoneIds() {
    return ZoneId.getAvailableZoneIds();
}