Example usage for java.time ZoneId getId

List of usage examples for java.time ZoneId getId

Introduction

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

Prototype

public abstract String getId();

Source Link

Document

Gets the unique time-zone ID.

Usage

From source file:Main.java

public static void main(String[] args) {
    ZoneId z = ZoneId.systemDefault();
    String s = z.getId();
    System.out.println(s);/*from  ww  w . j a va 2  s. c o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime now = LocalDateTime.now();
    ZoneId usChicago = ZoneId.of("America/Chicago");
    System.out.println("Zone ID:  " + usChicago.getId());

    ZoneRules rules = usChicago.getRules();
    System.out.println("isFixedOffset(): " + rules.isFixedOffset());
    ZoneOffset offset = rules.getOffset(now);
    System.out.println("Zone offset: " + offset);

    List<ZoneOffsetTransition> transitions = rules.getTransitions();
    System.out.println(transitions);

}

From source file:keepinchecker.network.PacketSniffer.java

private void sendPacketsToDatabase(Map<Timestamp, Packet> packetMap) throws Exception {
    Set<KeepInCheckerPacket> objectionablePackets = new HashSet<>();

    for (Map.Entry<Timestamp, Packet> entry : packetMap.entrySet()) {
        Timestamp packetTime = entry.getKey();
        ZoneId currentTimezone = ZonedDateTime.now().getZone();
        String packetString = PacketParser.convertToHumanReadableFormat(entry.getValue());

        for (String objectionableWord : Constants.OBJECTIONABLE_WORDS) {
            if (StringUtils.contains(packetString, objectionableWord)) {
                KeepInCheckerPacket packet = new KeepInCheckerPacket();

                packet.setTimestamp(packetTime.getTime());
                packet.setTimezone(currentTimezone.getId());

                String parsedGetValue = PacketParser.parse(PacketParser.GET, packetString);
                String parsedHostValue = PacketParser.parse(PacketParser.HOST, packetString);
                String parsedReferValue = PacketParser.parse(PacketParser.REFERER, packetString);
                packet.setGetValue(parsedGetValue.getBytes(StandardCharsets.UTF_8));
                packet.setHostValue(parsedHostValue.getBytes(StandardCharsets.UTF_8));
                packet.setRefererValue(parsedReferValue.getBytes(StandardCharsets.UTF_8));

                if (!areGetHostAndRefererValuesEmpty(packet)) {
                    objectionablePackets.add(packet);
                }//  ww w . j  a  va2  s .co m

                break;
            }
        }
    }

    if (!objectionablePackets.isEmpty()) {
        packetManager.savePackets(objectionablePackets);
    }
}

From source file:org.geoname.parser.TimeZoneDisplay.java

public TimeZoneDisplay(final ZoneId zoneId) {
    if (zoneId == null) {
        throw new IllegalArgumentException("Cannot use null time zone");
    }/*from  www. j  a v a 2s.c  o  m*/
    timeZoneId = zoneId.getId();
    timeZoneDisplayName = zoneId.getDisplayName(TextStyle.FULL, Locale.getDefault());
    description = createDescription();
}