Solved

Why are these 2 DAY_OF_WEEK different

Posted on 2004-10-13
1
185 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

707 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

17 Experts available now in Live!

Get 1:1 Help Now