Java Date Time - OffsetTime plusHours(long hours) example








OffsetTime plusHours(long hours) returns a copy of this OffsetTime with the specified period in hours added.

Syntax

plusHours has the following syntax.

public OffsetTime plusHours(long hours)

Example

The following example shows how to use plusHours.

import java.time.OffsetTime;
//from  w  w w .ja  v a2  s .  c  o  m
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    OffsetTime n = m.plusHours(34);
    System.out.println(n);

  }
}

The code above generates the following result.