Search in sources :

Example 81 with ZoneOffsetTransitionRule

use of java.time.zone.ZoneOffsetTransitionRule in project j2objc by google.

the class TCKZoneOffsetTransitionRule method test_toString_floatingWeekBackwards_last.

@Test
public void test_toString_floatingWeekBackwards_last() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]");
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) Test(org.junit.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 82 with ZoneOffsetTransitionRule

use of java.time.zone.ZoneOffsetTransitionRule in project j2objc by google.

the class TCKZoneOffsetTransitionRule method test_createTransition_floatingWeek_gap_notEndOfDay.

// -----------------------------------------------------------------------
// createTransition()
// -----------------------------------------------------------------------
@Test
public void test_createTransition_floatingWeek_gap_notEndOfDay() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransition trans = ZoneOffsetTransition.of(LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300);
    assertEquals(test.createTransition(2000), trans);
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition) Test(org.junit.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 83 with ZoneOffsetTransitionRule

use of java.time.zone.ZoneOffsetTransitionRule 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  environment: %s%n", indent, Environment.getEnvironment().getName());
    p.printf("%s process name: %s%n", indent, processName);
    p.printf("%s    user name: %s%n", indent, System.getProperty("user.name"));
    p.printf("%s         host: %s%n", indent, localHost);
    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());
    p.printf("%s  metrics dir: %s%n", indent, metricsDir);
    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)

Example 84 with ZoneOffsetTransitionRule

use of java.time.zone.ZoneOffsetTransitionRule 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)

Aggregations

ZoneOffsetTransitionRule (java.time.zone.ZoneOffsetTransitionRule)84 AbstractTCKTest (tck.java.time.AbstractTCKTest)72 Test (org.junit.Test)36 Test (org.testng.annotations.Test)36 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)22 ZoneRules (java.time.zone.ZoneRules)10 Instant (java.time.Instant)2 LocalDateTime (java.time.LocalDateTime)2 OffsetDateTime (java.time.OffsetDateTime)2 ZoneId (java.time.ZoneId)2 ZoneOffset (java.time.ZoneOffset)2 ZonedDateTime (java.time.ZonedDateTime)2 TimeDefinition (java.time.zone.ZoneOffsetTransitionRule.TimeDefinition)2 ArrayList (java.util.ArrayList)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 ThreadMXBean (java.lang.management.ThreadMXBean)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1