Found 4336 Articles for Java 8

LocalDate minusWeeks() Method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

123 Views

An immutable copy of the LocalDate where the weeks are subtracted from it can be obtained using the minusWeeks() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of weeks to be subtracted and it returns the instant with the subtracted weeks.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld1); ... Read More

LocalDate minusDays() Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

181 Views

An immutable copy of the LocalDate where the days are subtracted from it can be obtained using the minusDays() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of days to be subtracted and it returns the instant with the subtracted days.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld1); ... Read More

LocalDate plusYears() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

651 Views

An immutable copy of the LocalDate where the years are added to it can be obtained using the plusYears() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of years to be added and it returns the instant with the added years.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld1); ... Read More

LocalDate plusDays() Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

3K+ Views

An immutable copy of the LocalDate where the days are added to it can be obtained using the plusDays() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of days to be added and it returns the instant with the added days.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalDate ld1 = LocalDate.parse("2019-02-14");       System.out.println("The LocalDate is: " + ld1);       LocalDate ld2 = ld1.plusDays(5);       System.out.println("The LocalDate after ... Read More

LocalDate plusWeeks() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

211 Views

An immutable copy of the LocalDate where the weeks are added to it can be obtained using the plusWeeks() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of weeks to be added and it returns the instant with the added weeks.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld1); ... Read More

LocalDate plusMonths() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

799 Views

An immutable copy of the LocalDate where the months are added to it can be obtained using the plusMonths() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of months to be added and it returns the instant with the added months.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld1); ... Read More

Instant get() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

178 Views

The value of the required ChronoField for an Instant can be obtained using the get() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField and it returns the value of the ChronoField that was passed as a parameter.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       int micro = i.get(ChronoField.MICRO_OF_SECOND);       System.out.println("The current Instant is: " + i);       System.out.println("The MICRO_OF_SECOND ... Read More

Instant range() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

583 Views

The range of values for a field can be obtained using the range() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values are required and it returns the range of valid values for the ChronoField.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); ValueRange range1 = i.range(ChronoField.MILLI_OF_SECOND); ... Read More

Instant toString() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

167 Views

The range of values for a field can be obtained using the range() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values are required and it returns the range of valid values for the ChronoField.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); ValueRange range1 = i.range(ChronoField.MILLI_OF_SECOND); ... Read More

Instant parse() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

224 Views

The string representation of an Instant can be obtained using the toString() method in the Instant class in Java. This method requires no parameters and it returns the string representation of the Instant.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); System.out.println("The current Instant is: " + i.toString()); } }OutputThe current Instant is: 2019-02-13T09:01:52.484ZNow let us understand the above program.The string representation of the current ... Read More

Advertisements