• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

Why are these 2 DAY_OF_WEEK different

   public static void main(String args[]) {
        try {
            Calendar newCal1 = new GregorianCalendar(2004, Calendar.OCTOBER, 13);
            int day1 = newCal1.get(Calendar.DAY_OF_WEEK);
            System.out.println("newCal1 weekday is  " + day1);
           
            Calendar newCal2 = new GregorianCalendar(2004, 10, 13);
            int day2 = newCal2.get(Calendar.DAY_OF_WEEK);
            System.out.println("newCal2 weekday is " + day2);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
0
davidnlt
Asked:
davidnlt
1 Solution
 
objectsCommented:
because month numbers start at 0, not 1.

try:

 Calendar newCal2 = new GregorianCalendar(2004, 9, 13);
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now