Tue Jan 7 19:39:37 MST 2020 Let’s talk about today than shall we? I’d like to think it would be a nice moment in time if we could simply get along with everything that happens in this life, yet I doubt it will. It’s a shame if you think about it. A real shame. But what are you going to do with any of it? No one knows exactly. So here we sit waiting for something better to come along, hoping for something to happen and allowing us to actually see what is real and what isn’t.
Here's an easy method to return yesterday's date:
import java.time.LocalDateTime;
public class DoIt {
public static void main(String[] args) {
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
System.out.println(yesterday);
}
}
As you can see it's quite straight forward and simple. You just minus the number of days you wish to get. You can do this on a LocalDate or a LocalDateTime object.
From there you can do whatever you want with your past date.
Comments
Post a Comment