Close

Java Date Time - ZonedDateTime.plusHours() Examples

Java Date Time Java Java API 


Class:

java.time.ZonedDateTime

java.lang.Objectjava.lang.Objectjava.time.ZonedDateTimejava.time.ZonedDateTimejava.time.temporal.TemporalTemporaljava.time.chrono.ChronoZonedDateTimeChronoZonedDateTimejava.io.SerializableSerializableLogicBig

Method:

public ZonedDateTime plusHours(long hours)

Examples


package com.logicbig.example.zoneddatetime;

import java.time.ZonedDateTime;

public class PlusHoursExample {

public static void main(String... args) {
ZonedDateTime d = ZonedDateTime.now();
System.out.println(d);

ZonedDateTime d2 = d.plusHours(10);
System.out.println(d2);

ZonedDateTime d3 = d.plusHours(1000000);
System.out.println(d3);

ZonedDateTime d4 = d.plusHours(-1000000);
System.out.println(d4);
}
}

Output

2017-05-01T16:01:00.459-05:00[America/Chicago]
2017-05-02T02:01:00.459-05:00[America/Chicago]
2131-05-31T08:01:00.459-05:00[America/Chicago]
1903-04-03T23:01:00.459-06:00[America/Chicago]




See Also