Easy learning with example program codes

Java 8 ZonedDateTime class

The java.time.LocalDate class is an immutable class without a time-zone in the ISO-8601 calendar system, such as 2018-04-03.

Java ZonedDateTime class methods

Method Description
String format(DateTimeFormatter formatter) It is used to format this date-time using the specified formatter.
int get(TemporalField field) It is used to get the value of the specified field from this date-time as an int.
ZoneId getZone() It is used to get the time-zone, such as ‘Asia/Kolkata’.
ZonedDateTime withZoneSameInstant(ZoneId zone) It is used to return a copy of this date-time with a different time-zone, retaining the instant.
static ZonedDateTime now() It is used to obtain the current date-time from the system clock in the default time-zone.
static ZonedDateTime of(LocalDate date, LocalTime time, ZoneId zone) It is used to obtain an instance of ZonedDateTime from a local date and time.
ZonedDateTime minus(long amountToSubtract, TemporalUnit unit) It is used to return a copy of this date-time with the specified amount subtracted.
ZonedDateTime plus(long amountToAdd, TemporalUnit unit) It is used to return a copy of this date-time with the specified amount added.


package com.codesjava;
import java.time.Period;
import java.time.ZonedDateTime;
public class TestExample {
	public static void main(String args[]){
		ZonedDateTime zone = 
	    //Get zone
	    //Use of minus()
	    //Use of plus()


Posted in Date   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki