java date add one day
javaTo add a day to a java.time.LocalDate object, you can use the plusDays() method.
Here’s an example:
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
LocalDate date = LocalDate.now();
System.out.println("Current date: " + date);
// Add 1 day to the current date
LocalDate nextDay = date.plusDays(1);
System.out.println("Next day: " + nextDay);
}
}
You can also use the plus() method with a java.time.Period object to add a specific number of days, months, and years:
import java.time.LocalDate;
import java.time.Period;
public class Main {
public static void main(String[] args) {
LocalDate date = LocalDate.now();
System.out.println("Current date: " + date);
// Add 1 day, 2 months, and 3 years to the current date
LocalDate future = date.plus(Period.of(3, 2, 1));
System.out.println("Future date: " + future);
}
}
Other Article on Tag java
- - after and before in java date
- - am pm java date format
- - apk minecraft java edition
- - as been blocked by CORS policy Response to preflight request doesn't pass access control check It does not have HTTP ok status
- - bubble sort in java
- - Can I compile and run a spring boot jar from inside another spring boot application
- - convert java date to localdate
- - design patterns in java
- - encrypt by java and decrypt by node
- - exception handling in java