Solved

Why are these 2 DAY_OF_WEEK different

Posted on 2004-10-13
1
225 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 125 total points
ID: 12304408
because month numbers start at 0, not 1.

try:

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

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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…

724 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