Ob es richtig ist, zu nehmen 01/01/0001 Datum als am Montag?

Schreibe ich ein Programm zum anzeigen der Tag für ein bestimmtes Datum. (E. g. Donnerstag für 1/1/1970.)
Beim Versuch, dass ich einige Probleme haben.

Dies ist mein Programm.

/*Concept: 
 The noOfDays variable will count the no of days since 01/01/0001. And this will be Day one(1). E.g 
 noOfDays = 365 for 01/12/0001 and noOfDays = 731 for 01/01/0003 and so on....
 Since I taken Monday as 01/01/0001,the day of the specific date can be achieved by switching(noOfDays%7)
 E.g. 365 % 7 = 1. So, the 365th day is monday...
*/

import java.util.Scanner;
class DayDisplayer
{
    long noOfDays;
    int month;
    int days;
    int year;
    Scanner scan;
    int countYear;
    int countMonth;

    DayDisplayer()
    {
        scan = new Scanner(System.in);
        noOfDays = 0;
        System.out.println("Enter the date please");

        days = scan.nextInt();
        month = scan.nextInt();
        year = scan.nextInt();

        System.out.println("Your Date is:  "+days+"/"+month+"/"+year);



    }

    boolean leapYearCheck(int year)
    {
        if( ((year%100 == 0) && (year%400 != 0)) || (year%4 != 0) )  //when it is divisible by 100 and not by 400.  
            return false;
        else
            return true;

    }

    boolean isThere31Days()
    {
        if ( ( (countMonth >> 3) ^ (countMonth & 1) ) == 1 ) 
            return true;
        else 
            return false;

    }

    void getDaysThatInDays()    
    {
        noOfDays += days;
    }

    void getDaysThatInMonth()
    {

        countMonth = 1;

        while(countMonth<month)
        {
            if( countMonth == 2 )
                if( leapYearCheck(year) == true)
                    noOfDays += 29;
                else 
                    noOfDays += 28;
            else
               if ( isThere31Days()) 
                   noOfDays += 31;
               else 
                   noOfDays += 30;

            countMonth++;
        }                   



    }

    void getDaysThatInYear()
    {
        countYear = 1;

        while(countYear<year)
        {
            if( leapYearCheck(countYear)== true )  
                    noOfDays += 366; 
                else 
                    noOfDays += 365;

            countYear ++;
        }
    }

    void noOfDaysAndDayName()
    {
        System.out.println("The noOfDays is"+noOfDays);

        System.out.println("And Your Day is :"); 

        int day;

        day = (int)(noOfDays%7);
        switch(day)
        {

        case 0:
            System.out.println("Sunday");
            break;
        case 1:
            System.out.println("Monday");
            break;
        case 2:
            System.out.println("Tuesday");
            break; 
        case 3:
            System.out.println("Wednesday");
            break;
        case 4:
            System.out.println("Thursday");
            break;
        case 5:
            System.out.println("Friday");
            break;
        case 6:
            System.out.println("Saturday");
            break;
        }

    }

}//end of MonthToDate class

public class Main
{
    public static void main(String args[])
    {

        DayDisplayer  dd= new DayDisplayer();

        dd.getDaysThatInYear();
        dd.getDaysThatInMonth();
        dd.getDaysThatInDays();

        dd.noOfDaysAndDayName();


    }



}

In diesem code ,wenn ich 01/01/0001 als am Montag und berechnet die anderen Tage. Und ich bin immer korrekte Antworten.

Aber In www.timeanddate.com website Sie nahm 01/01/0001 wie Samstag.
Aber immer noch für die anderen neueren Datums (sagen 17/7/2011) Sie sind die richtige Antwort geben (wie am Sonntag).

Könnte ich denke, diese lags sind aufgrund der migration von Julier-system Gregorianischen system.

Aber ich habe Zweifel, ob mein Ansatz der Berechnung der Tage vom 0001 Jahr korrekt ist oder nicht?

Auch ich habe Zweifel, ob 01/01/0001 Datum ein Montag ist oder Samstag.
(Und Wenn ich Samstag zu meinem ersten Tag bin ich immer falsche Antworten.)

bitte jemand erklären.

Vielen Dank im Voraus.

  • Sie vergaß die Hausaufgaben-tag...
  • Sie auch vergessen, ein tag für die Programmiersprache, die Sie verwenden
Schreibe einen Kommentar