One would think this life would be easier than it currently is. I mean come on wouldn’t ou think that? Of course you would. So why can’t we each believe in it I for one would want to believe in it. It would give me something to do with my day at least. But well there’s something else on my mind. We have to be able to understand what it is exactly, if we don’t? Then that’s something quite different now isn’t it? Yeah that’s what I was thinking.
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