In this tutorial, I will share a Java program to get yesterday’s date with an output. Copy the below and execute it with the help of Java compiler and see the output.
In this program, I have used pre-define classes:
2) java.text.DateFormat and
At the end of this tutorial, I shared the output of this Java program. It will print the date in “dd MMM yyyy” format.
public static void main(String args)
Calendar cal = Calendar.getInstance();
//Set the format date
DateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");
System.out.println("Yesterday's date = "+ yesterdayDate);
Yesterday’s date = 12 January 2016
Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies. View all posts by Prem Tiwari