get Time Zone Offsets - Java java.time

Java examples for java.time:Timezone

Description

get Time Zone Offsets

Demo Code



//package com.java2s;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.stream.Collectors;

public class Main {
  public static Map<String, ZoneOffset> getTimeZoneOffsets(LocalDateTime localDateTime) {
    return ZoneId.getAvailableZoneIds().stream()
        .collect(Collectors.toMap(id -> id, id -> ZonedDateTime.of(localDateTime, ZoneId.of(id)).getOffset()));
  }/* w ww .ja v  a 2 s.  co m*/
}

Related Tutorials