Returns the current OffsetTime from the system clock in the default time-zone.
Returns the current OffsetTime from the system clock and in the provided ZoneId.
Returns the current date-time from provided clock.
package com.logicbig.example.offsettime;
import java.time.OffsetTime;
import java.time.ZoneId;
public class NowExample2 {
public static void main(String... args) {
OffsetTime d = OffsetTime.now(ZoneId.systemDefault());
System.out.println(d);
d = OffsetTime.now(ZoneId.of("-3"));
System.out.println(d);
d = OffsetTime.now(ZoneId.of("GMT+01:00"));
System.out.println(d);
d = OffsetTime.now(
ZoneId.of("America/Argentina/Buenos_Aires"));
System.out.println(d);
}
}
Output
16:13:47.130-05:00
18:13:47.169-03:00
22:13:47.169+01:00
18:13:47.169-03:00