?
Solved

Why are these 2 DAY_OF_WEEK different

Posted on 2004-10-13
1
Medium Priority
?
228 Views
Last Modified: 2010-03-31
   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
Comment
Question by:davidnlt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12304408
because month numbers start at 0, not 1.

try:

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

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question