I want to do something like:
Date date = new Date(); // current date
date = date - 300; // substract 300 days from current date and I want to use this "date"
How to do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Java 8 and later
With Java 8’s date time API change, Use
LocalDateSimilarly you can have
Refer to https://stackoverflow.com/a/23885950/260990 for translation between java.util.Date <–> java.time.LocalDateTime
Java 7 and earlier
Use
Calendar‘sadd()method