Example usage for java.time LocalTime now

List of usage examples for java.time LocalTime now

Introduction

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

Prototype

public static LocalTime now(Clock clock) 

Source Link

Document

Obtains the current time from the specified clock.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalTime l = LocalTime.now(Clock.systemUTC());

    System.out.println(l);
}

From source file:Main.java

public static void main(String[] args) {
    LocalTime l = LocalTime.now(ZoneId.systemDefault());

    System.out.println(l);
}

From source file:Main.java

public static void main(String[] args) {
    LocalTime nowInUtc = LocalTime.now(Clock.systemUTC());
    System.out.println(nowInUtc); // 06:08:18.125
}

From source file:Main.java

public static void main(String[] args) {

    LocalTime currentTimeInLosAngeles = LocalTime.now(ZoneId.of("America/Los_Angeles"));
    System.out.println(currentTimeInLosAngeles); // 23:08:18.104
}

From source file:Main.java

public static void main(String[] args) {
    // Current time in "Asia/Kolkata"
    LocalTime timeKolkata = LocalTime.now(ZoneId.of("Asia/Kolkata"));
    System.out.println("Current Time in IST=" + timeKolkata);
}

From source file:Main.java

public static void main(String... args) {
    ZoneId zone1 = ZoneId.of("Europe/Berlin");
    ZoneId zone2 = ZoneId.of("Brazil/East");

    LocalTime now1 = LocalTime.now(zone1);
    LocalTime now2 = LocalTime.now(zone2);

    System.out.println(now1);/*w w w. java  2s  .  c  o m*/
    System.out.println(now2);

}

From source file:Main.java

public static void main(String... args) {
    ZoneId zone1 = ZoneId.of("Europe/Berlin");
    ZoneId zone2 = ZoneId.of("Brazil/East");

    LocalTime now1 = LocalTime.now(zone1);
    LocalTime now2 = LocalTime.now(zone2);

    System.out.println(now1);//  w w w . j  a v a 2  s.  c  o  m
    System.out.println(now2);

    System.out.println(now1.isBefore(now2)); // false

}

From source file:Main.java

public static void main(String... args) {
    ZoneId zone1 = ZoneId.of("Europe/Berlin");
    ZoneId zone2 = ZoneId.of("Brazil/East");

    LocalTime now1 = LocalTime.now(zone1);
    LocalTime now2 = LocalTime.now(zone2);

    System.out.println(now1);/* w w  w  .  ja v  a2s  . c  o  m*/
    System.out.println(now2);

    long hoursBetween = ChronoUnit.HOURS.between(now1, now2);
    long minutesBetween = ChronoUnit.MINUTES.between(now1, now2);
    System.out.println(hoursBetween);
    System.out.println(minutesBetween);

}