OffsetTime withHour(int hour) example

Description

OffsetTime withHour(int hour) returns a copy of this OffsetTime with the hour-of-day value altered.

Syntax

withHour has the following syntax.


public OffsetTime withHour(int hour)

Example

The following example shows how to use withHour.


import java.time.OffsetTime;
//  w  w w.j  ava  2s .c  o  m
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    OffsetTime n = m.withHour(4);
    System.out.println(n);

  }
}

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