ZoneOffset ofTotalSeconds(int totalSeconds) example

Description

ZoneOffset ofTotalSeconds(int totalSeconds) creates an instance of ZoneOffset specifying the total offset in seconds.

The offset must be in the range -18:00 to +18:00, which corresponds to -64800 to +64800.

Syntax

ofTotalSeconds has the following syntax.


public static ZoneOffset ofTotalSeconds(int totalSeconds)

Example

The following example shows how to use ofTotalSeconds.


import java.time.ZoneOffset;
/*from  w  w w. j a  v  a  2 s .  com*/
public class Main {
  public static void main(String[] args) {
    ZoneOffset t = ZoneOffset.ofTotalSeconds(2000);
    System.out.println(t);
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset