Search in sources :

Example 51 with ZoneOffsetTransition

use of java.time.zone.ZoneOffsetTransition in project jPOS by jpos.

the class TZCHECK method exec.

public void exec(CLIContext cli, String[] args) throws Exception {
    ZoneId zi = ZoneId.systemDefault();
    Instant i = Instant.now();
    cli.println("         Zone ID: " + zi + " (" + zi.getDisplayName(TextStyle.FULL, Locale.getDefault()) + ") " + zi.getRules().getOffset(i));
    cli.println("             UTC: " + i);
    ZoneOffsetTransition tran = zi.getRules().nextTransition(i);
    if (tran != null) {
        Instant in = tran.getInstant();
        cli.println(" Next transition: " + in + " (" + in.atZone(zi) + ")");
    }
    List<ZoneOffsetTransitionRule> l = zi.getRules().getTransitionRules();
    for (ZoneOffsetTransitionRule r : l) {
        cli.println(" Transition rule: " + r);
    }
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) ZoneId(java.time.ZoneId) Instant(java.time.Instant) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Example 52 with ZoneOffsetTransition

use of java.time.zone.ZoneOffsetTransition in project jPOS by jpos.

the class SystemMonitor method generateFrozenDump.

private String generateFrozenDump(String indent) {
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream p = new PrintStream(baos);
    String newIndent = indent + "  ";
    Runtime r = getRuntimeInstance();
    ZoneId zi = ZoneId.systemDefault();
    Instant instant = Instant.now();
    File cwd = new File(".");
    String freeSpace = ISOUtil.readableFileSize(cwd.getFreeSpace());
    String usableSpace = ISOUtil.readableFileSize(cwd.getUsableSpace());
    p.printf("%s           OS: %s (%s)%n", indent, System.getProperty("os.name"), System.getProperty("os.version"));
    int maxKeyLength = 0;
    try {
        maxKeyLength = Cipher.getMaxAllowedKeyLength("AES");
    } catch (NoSuchAlgorithmException ignored) {
    }
    p.printf("%s         Java: %s (%s) AES-%s%n", indent, System.getProperty("java.version"), System.getProperty("java.vendor"), maxKeyLength == Integer.MAX_VALUE ? "secure" : Integer.toString(maxKeyLength));
    p.printf("%s process name: %s%n", indent, runtimeMXBean.getName());
    p.printf("%s         host: %s%n", indent, getLocalHost());
    p.printf("%s          cwd: %s%n", indent, System.getProperty("user.dir"));
    p.printf("%s   free space: %s%n", indent, freeSpace);
    if (!freeSpace.equals(usableSpace))
        p.printf("%s usable space: %s%n", indent, usableSpace);
    p.printf("%s      version: %s (%s)%n", indent, Q2.getVersion(), getRevision());
    p.printf("%s     instance: %s%n", indent, getInstanceIdAsString());
    p.printf("%s       uptime: %s (%f)%n", indent, ISOUtil.millisToString(getServerUptimeAsMillisecond()), loadAverage());
    p.printf("%s   processors: %d%n", indent, r.availableProcessors());
    p.printf("%s       drift : %d%n", indent, delay);
    p.printf("%smemory(t/u/f): %d/%d/%d%n", indent, r.totalMemory() / MB, (r.totalMemory() - r.freeMemory()) / MB, r.freeMemory() / MB);
    p.printf("%s     encoding: %s%n", indent, Charset.defaultCharset());
    p.printf("%s     timezone: %s (%s) %s%n", indent, zi, zi.getDisplayName(TextStyle.FULL, Locale.getDefault()), zi.getRules().getOffset(instant).toString());
    p.printf("%swatch service: %s%n", indent, getServer().getWatchServiceClassname());
    List<ZoneOffsetTransitionRule> l = zi.getRules().getTransitionRules();
    for (ZoneOffsetTransitionRule tr : l) {
        p.printf("%s         rule: %s%n", indent, tr.toString());
    }
    ZoneOffsetTransition tran = zi.getRules().nextTransition(instant);
    if (tran != null) {
        Instant in = tran.getInstant();
        p.printf("%s   transition: %s (%s)%n", indent, in, in.atZone(zi));
    }
    p.printf("%s        clock: %d %s%n", indent, System.currentTimeMillis() / 1000L, instant);
    if (hasSecurityManager())
        p.printf("%s  sec-manager: %s%n", indent, getSecurityManager());
    p.printf("%s thread count: %d%n", indent, mxBean.getThreadCount());
    p.printf("%s peak threads: %d%n", indent, mxBean.getPeakThreadCount());
    p.printf("%s user threads: %d%n", indent, Thread.activeCount());
    showThreadGroup(Thread.currentThread().getThreadGroup(), p, newIndent);
    NameRegistrar.getInstance().dump(p, indent, detailRequired);
    for (String s : scripts) {
        p.printf("%s%s:%n", indent, s);
        exec(s, p, newIndent);
    }
    return baos.toString();
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) ThreadMXBean(java.lang.management.ThreadMXBean) ZoneId(java.time.ZoneId) Instant(java.time.Instant) RuntimeMXBean(java.lang.management.RuntimeMXBean) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Aggregations

ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)52 LocalDateTime (java.time.LocalDateTime)26 ZoneRules (java.time.zone.ZoneRules)22 Test (org.testng.annotations.Test)20 AbstractTCKTest (tck.java.time.AbstractTCKTest)20 ZoneOffsetTransitionRule (java.time.zone.ZoneOffsetTransitionRule)12 ZoneId (java.time.ZoneId)8 Instant (java.time.Instant)4 ZoneOffset (java.time.ZoneOffset)4 ZonedDateTime (java.time.ZonedDateTime)3 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 ThreadMXBean (java.lang.management.ThreadMXBean)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 OffsetDateTime (java.time.OffsetDateTime)1 TimeDefinition (java.time.zone.ZoneOffsetTransitionRule.TimeDefinition)1 ArrayList (java.util.ArrayList)1