OffsetTime
Description
OffsetTime represents a time with a fixed zone offset from UTC.
OffsetTime combines LocalTime and ZoneOffset.
System default time zone is used to obtain the zone offset value when using now() on offset time.
Example
The following code shows how to create offset time.
import java.time.OffsetTime;
import java.time.ZoneOffset;
//from w w w.j a v a2 s . c o m
public class Main {
public static void main(String[] args) {
// current offset time
OffsetTime ot1 = OffsetTime.now();
System.out.println("Current offset time: " + ot1);
// a zone offset +01:30
ZoneOffset offset = ZoneOffset.ofHoursMinutes(1, 30);
OffsetTime offsetTime = OffsetTime.of(16, 40, 28, 0, offset);
System.out.println(offsetTime);
}
}
The code above generates the following result.