Solved

Why are these 2 DAY_OF_WEEK different

Posted on 2004-10-13
1
193 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
1 Comment
 
LVL 92

Accepted Solution

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

try:

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

948 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now