-3

How would I get the current day of the week? Can some please help me?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

2 Answers2

3

Use a Calendar and get the DAY_OF_WEEK field:

Calendar cal = Calendar.getInstance();
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);

Or if you want the day name instead, you can use SimpleDateFormat:

Date today = Calendar.getInstance().getTime();
DateFormat df = new SimpleDateFormat("EEEE", Locale.ENGLISH); // override the default Locale
String dayNameInWeek = df.format(today);
João Silva
  • 89,303
  • 29
  • 152
  • 158
0

To get a text display of the day of the week you can use:

DateFormat dateFormat = new SimpleDateFormat("EEEE");
System.out.println("Today is " + dateFormat.format(new Date()));

output:

Today is Sunday
Reimeus
  • 158,255
  • 15
  • 216
  • 276