0

I am trying to get the current time in android app. here is my code:

Calendar cal = Calendar.getInstance();
Date date = new Date();
cal.setTime(date);
System.out.println(cal.get(Calendar.DAY_OF_WEEK));

today is Wednesday. the output should be 3. but it is 4.

can someone help me with this?

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
Jensen
  • 85
  • 1
  • 6
  • 2
    it has been asked and answered here. http://stackoverflow.com/questions/6689435/java-calendar-using-calendar-day-of-week-to-get-the-first-and-the-last-dates-for – Yu Zhang Sep 02 '15 at 00:56
  • This is a duplicate question, but also, have you considered that java/android thinks Sunday = 1, Monday = 2, etc.? So if you want Wednesday to be 3, just subtract 1 from your answer – Aaron Troeger Sep 02 '15 at 01:18

0 Answers0