-3

I'm working on a task where I need to provide specific day like Wednesday, Thursday etc on given input date like
Input:
6 7 2017
Output:
Wednesday

Any help would be appreciated thank you.

I have tried using java.util.Calendar. I am able to get output like "Sat Sep 05 08:18:27 UTC 2015" but I need only day of week.

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • 2
    Okay, so you've got a task - have you tried *anything* yet? Do you definitely want English? Are you able to use java.time from Java 8? (I'd strongly advise that instead of java.util.Calendar etc.) We can help you, but we're not just going to write the code for you. – Jon Skeet Jun 07 '17 at 08:15
  • 2
    Maybe this discussion solves it. https://stackoverflow.com/questions/5270272/how-to-determine-day-of-week-by-passing-specific-date – Glfpes Jun 07 '17 at 08:17
  • 1
    I used java calendar. From which I can able to get output like "Sat Sep 05 08:18:27 UTC 2015" but I need only 'day'. – Naveen Akula Jun 07 '17 at 08:19
  • 2
    So you've got some code - you should post that in your question. Although I'd strongly recommend *not* using java.util.Calendar. – Jon Skeet Jun 07 '17 at 08:19

3 Answers3

1

I would follow these steps:

assylias
  • 321,522
  • 82
  • 660
  • 783
1

Using java8 you will need a local date and the call the method getDayOfWeek(), which returns an enum with the info you need

example:

 LocalDate date = LocalDate.now();
 DayOfWeek dayOfWeek = date.getDayOfWeek();
 System.out.println(dayOfWeek);
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
0

Try this

SimpleDateFormat format1=new SimpleDateFormat("MM/dd/yyyy");
      Date dt1=format1.parse(pass your date);
      DateFormat format2=new SimpleDateFormat("EEEE"); 
      String finalDay=format2.format(dt1);
Vikram Saini
  • 2,713
  • 1
  • 16
  • 33