Instant plus() method in Java with Examples Last Updated : 27 Dec, 2018 Comments Improve Suggest changes Like Article Like Report In Instant class, there are two types of plus() method depending upon the parameters passed to it. plus(long amountToAdd, TemporalUnit unit) plus() method of a Instant class used to return a copy of this instant with the specified amount of unit added.If it is not possible to add the amount, because the unit is not supported or for some other reason, an exception is thrown. This instance is immutable and unaffected by this method call. Syntax: public Instant plus(long amountToAdd, TemporalUnit unit) Parameters: This method accepts two parameters amountToAdd which is the amount of the unit to add to the result, may be negative and unit which is the unit of the amount to add, not null. Return value: This method returns Instant based on this instant with the specified amount added. Below programs illustrate the plus() method: Program 1: Java // Java program to demonstrate // Instant.plus() method import java.time.*; import java.time.temporal.ChronoUnit; public class GFG { public static void main(String[] args) { // create an Instant object Instant instant = Instant.parse("2018-12-30T19:34:50.63Z"); // add 30 DAYS to Instant Instant value = instant.plus(30, ChronoUnit.DAYS); // print result System.out.println("Instant after adding 30 DAYS: " + value); } } Output: Instant after adding 30 DAYS: 2019-01-29T19:34:50.630Z plus(TemporalAmount amountToAdd) plus() method of a Instant class used to return a copy of this instant with the specified amount added to date-time.The amount is typically Period or Duration but may be any other type implementing the TemporalAmount interface. Syntax: public Instant plus(TemporalAmount amountToAdd) Parameters: This method accepts one single parameter amountToAdd which is the amount to add, It should not be null. Return value: This method returns Instant based on this instant with the addition made, not null Below programs illustrate the plus() method: Program 1: Java // Java program to demonstrate // Instant.plus() method import java.time.*; public class GFG { public static void main(String[] args) { // create a Instant object Instant inst = Instant.parse("2018-12-30T19:34:50.63Z"); // add 20 Days to Instant Instant value = inst.plus(Period.ofDays(10)); // print result System.out.println("Instant after adding Days: " + value); } } Output: Instant after adding Days: 2019-01-09T19:34:50.630Z References: https://docs.oracle.com/javase/10/docs/api/java/time/Instant.html#plus(java.time.temporal.TemporalAmount) https://docs.oracle.com/javase/10/docs/api/java/time/Instant.html#plus(long, java.time.temporal.TemporalUnit) Comment More infoAdvertise with us Next Article Instant plus() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions Java-Instant Java-time package Practice Tags : Java Similar Reads Instant minus() method in Java with Examples In Instant class, there are two types of minus() method depending upon the parameters passed to it. minus(long amountTosubtract, TemporalUnit unit) minus() method of a Instant class used to returns a copy of this instant with the specified amount of unit subtracted.If it is not possible to subtract 2 min read Instant parse() method in Java with Examples The parse() method of Instant class help to get an instance of Instant from a string value passed as parameter. This string is an instant in the UTC time zone. It is parsed using DateTimeFormatter.ISO_INSTANT. Syntax: public static Instant parse(CharSequence text) Parameters: This method accepts one 1 min read Instant plusNanos() method in Java with Examples The plusNanos() method of Instant class adds nanoseconds value passed as parameter to this instant and return the result as an instant object. This returned Instant is immutable. Syntax: public Instant plusNanos(long nanosToAdd) Parameters: This method accepts one parameter nanosToAdd which is nanos 2 min read Instant plusMillis() method in Java with Examples The plusMillis() method of Instant class adds specified duration in milliseconds to this instant and returns the result as an instant object. This returned Instant is immutable. Syntax: public Instant plusMillis(long millisToAdd) Parameters: This method accepts one parameter millisToAdd which is mil 2 min read Instant until() Method in Java with Examples until() method of an Instant class used to calculate the amount of time between two Instant objects using TemporalUnit. The start and end points are this and the specified instant passed as a parameter. The result will be negative if the end is before the start. The calculation returns a whole numbe 2 min read Instant query() Method in Java with Examples query() method of an Instant class used to query this instant using the specified query as parameter.The TemporalQuery object passed as parameter define the logic to be used to obtain the result from this instant. Syntax: public <R> R query(TemporalQuery<R> query) Parameters: This method 2 min read Instant plusSeconds() method in Java with Examples The plusSeconds() method of Instant class adds seconds value passed as parameter to this instant and return the result as an instant object. This returned Instant is immutable. Syntax: public Instant plusSeconds(long secondsToAdd) Parameters: This method accepts one parameter secondsToAdd which is s 2 min read Instant now() Method in Java with Examples In Instant class, there are two types of now() method depending upon the parameters passed to it. now() now() method of a Instant class used to obtain the current instant from the system UTC clock.This method will return instant based on system UTC clock. Syntax: public static Instant now() Paramete 2 min read Instant with() Method in Java with Examples In Instant class, there are two types of with() method depending upon the parameters passed to it. with(TemporalAdjuster adjuster) with(TemporalAdjuster adjuster) method of the Instant class used to adjusted this instant using TemporalAdjuster and after adjustment returns the copy of adjusted instan 3 min read Instant get() method in Java with Examples The get() method of Instant class helps to get the value for the specified field passed as parameter from this instant as an integer value. This method queries this instant for the value of the field and the returned value will always be within the valid range of values for the field. When the field 2 min read Like