Example usage for java.time LocalTime ofSecondOfDay

List of usage examples for java.time LocalTime ofSecondOfDay

Introduction

In this page you can find the example usage for java.time LocalTime ofSecondOfDay.

Prototype

public static LocalTime ofSecondOfDay(long secondOfDay) 

Source Link

Document

Obtains an instance of LocalTime from a second-of-day value.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalTime l = LocalTime.ofSecondOfDay(10000);

    System.out.println(l);
}

From source file:Main.java

public static void main(String[] args) {
    LocalTime currentTime = LocalTime.now(); // current time
    System.out.println(currentTime);

    LocalTime midday = LocalTime.of(12, 0); // 12:00
    System.out.println(midday); // 12:00

    LocalTime afterMidday = LocalTime.of(13, 30, 15); // 13:30:15
    System.out.println(afterMidday); // 13:30:15

    // 12345th second of day (03:25:45)
    LocalTime fromSecondsOfDay = LocalTime.ofSecondOfDay(12345);
    System.out.println(fromSecondsOfDay); // 03:25:45
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate february20th = LocalDate.of(2014, Month.FEBRUARY, 20);
    System.out.println(february20th);
    System.out.println(LocalDate.from(february20th.plus(15, ChronoUnit.YEARS))); // 2029-02-20
    System.out.println(LocalDate.MAX);
    System.out.println(LocalDate.MIN);

    System.out.println(LocalTime.MIDNIGHT); // 00:00
    System.out.println(LocalTime.NOON); // 12:00
    System.out.println(LocalTime.of(23, 12, 30, 500)); // 23:12:30.000000500
    System.out.println(LocalTime.now()); // 00:40:34.110
    System.out.println(LocalTime.ofSecondOfDay(11 * 60 * 60)); // 11:00
    System.out.println(LocalTime.from(LocalTime.MIDNIGHT.plusHours(4))); // 04:00
    System.out.println(LocalTime.MIN);
    System.out.println(LocalTime.MAX);

    System.out.println(LocalDateTime.of(2014, 2, 15, 12, 30, 50, 200)); // 2014-02-15T12:30:50.000000200
    System.out.println(LocalDateTime.now()); // 2014-02-28T17:28:21.002
    System.out.println(LocalDateTime.from(LocalDateTime.of(2014, 2, 15, 12, 30, 40, 500).plusHours(19))); // 2014-02-16T07:30:40.000000500
    System.out.println(LocalDateTime.MAX);
}

From source file:Main.java

public static void main(String[] args) {

    // the current date
    LocalDate currentDate = LocalDate.now();

    // 2014-02-10
    LocalDate tenthFeb2014 = LocalDate.of(2014, Month.FEBRUARY, 10);

    // months values start at 1 (2014-08-01)
    LocalDate firstAug2014 = LocalDate.of(2014, 8, 1);

    // the 65th day of 2010 (2010-03-06)
    LocalDate sixtyFifthDayOf2010 = LocalDate.ofYearDay(2010, 65);

    // times, e.g. 19:12:30.733

    LocalTime currentTime = LocalTime.now(); // current time
    LocalTime midday = LocalTime.of(12, 0); // 12:00
    LocalTime afterMidday = LocalTime.of(13, 30, 15); // 13:30:15

    // 12345th second of day (03:25:45)
    LocalTime fromSecondsOfDay = LocalTime.ofSecondOfDay(12345);

    // dates with times, e.g. 2014-02-18T19:08:37.950
    LocalDateTime currentDateTime = LocalDateTime.now();

    // 2014-10-02 12:30
    LocalDateTime secondAug2014 = LocalDateTime.of(2014, 10, 2, 12, 30);

    // 2014-12-24 12:00
    LocalDateTime christmas2014 = LocalDateTime.of(2014, Month.DECEMBER, 24, 12, 0);

    // current (local) time in Los Angeles
    LocalTime currentTimeInLosAngeles = LocalTime.now(ZoneId.of("America/Los_Angeles"));

    // current time in UTC time zone
    LocalTime nowInUtc = LocalTime.now(Clock.systemUTC());

    System.out.println("date/time creation: currentDate: " + currentDate);
    System.out.println("date/time creation: tenthFeb2014: " + tenthFeb2014);
    System.out.println("date/time creation: firstAug2014: " + firstAug2014);
    System.out.println("date/time creation: sixtyFifthDayOf2010: " + sixtyFifthDayOf2010);
    System.out.println("date/time creation: currentTime: " + currentTime);
    System.out.println("date/time creation: midday: " + midday);
    System.out.println("date/time creation: afterMidday: " + afterMidday);
    System.out.println("date/time creation: fromSecondsOfDay: " + fromSecondsOfDay);
    System.out.println("date/time creation: currentTimeInLosAngeles: " + currentTimeInLosAngeles);
    System.out.println("date/time creation: currentDateTime: " + currentDateTime);
    System.out.println("date/time creation: secondAug2014: " + secondAug2014);
    System.out.println("date/time creation: christmas2014: " + christmas2014);
}

From source file:com.github.benmanes.caffeine.cache.Stresser.java

private void status() {
    local.evictionLock.lock();//w  w  w  .java 2s.  c om
    int pendingWrites = local.writeBuffer().size();
    int drainStatus = local.drainStatus();
    local.evictionLock.unlock();

    LocalTime elapsedTime = LocalTime.ofSecondOfDay(stopwatch.elapsed(TimeUnit.SECONDS));
    System.out.printf("---------- %s ----------%n", elapsedTime);
    System.out.printf("Pending reads: %,d; writes: %,d%n", local.readBuffer.size(), pendingWrites);
    System.out.printf("Drain status = %s (%s)%n", STATUS[drainStatus], drainStatus);
    System.out.printf("Evictions = %,d%n", cache.stats().evictionCount());
    System.out.printf("Size = %,d (max: %,d)%n", local.data.mappingCount(), operation.maxEntries);
    System.out.printf("Lock = [%s%n", StringUtils.substringAfter(local.evictionLock.toString(), "["));
    System.out.printf("Pending tasks = %,d%n", ForkJoinPool.commonPool().getQueuedSubmissionCount());

    long maxMemory = Runtime.getRuntime().maxMemory();
    long freeMemory = Runtime.getRuntime().freeMemory();
    long allocatedMemory = Runtime.getRuntime().totalMemory();
    System.out.printf("Max Memory = %,d bytes%n", maxMemory);
    System.out.printf("Free Memory = %,d bytes%n", freeMemory);
    System.out.printf("Allocated Memory = %,d bytes%n", allocatedMemory);

    System.out.println();
}