Here we can see java program to show current date and week. This java program to find current date and week using this java program.
Program Code
package com.androidpro.in;
import java.util.*;
public class Main {
public static void main(String[] args)
{
//create
Calendar instance
Calendar now =
Calendar.getInstance();
System.out.println("Current
Date : " + (now.get(Calendar.MONTH) + 1)
+ "-"
+
now.get(Calendar.DATE)
+ "-"
+
now.get(Calendar.YEAR));
//create
an array of days
String[] strDays
= new String[]{
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thusday",
"Friday",
"Saturday"
};
//Day_OF_WEEK
starts from 1 while array index starts from 0
System.out.println("Current
Day Is : " +
strDays[now.get(Calendar.DAY_OF_WEEK) - 1]
);
}
}
Output
Current Date : 1-2-2022
Current Day Is : Sunday
Process finished with exit code 0