今日の日付、曜日、100日後の日付、100日後の曜日、誕生日、曜日など、いくつかのことを印刷しようとしています。 、および私の誕生日とその曜日から10、000日後。さて、GregorianCalendarは1月は0から始まり、12月は11になることを理解しています。私はそれを理解しているので、今日の日付が9/25/12ではなく8/25/12であると表示されている日付を印刷しようとすると意味がありますが、日付を余分に設定せずにこれを修正する方法がわかりません月を作成し、実際にその月を9月ではなく10月に入れます。
これが私が現在扱っていることです。
GregorianCalendar cal = new GregorianCalendar();
int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int weekday = cal.get(Calendar.DAY_OF_WEEK);
cal.add(Calendar.DAY_OF_MONTH, 100);
int dayOfMonth2 = cal.get(Calendar.DAY_OF_MONTH);
int month2 = cal.get(Calendar.MONTH);
int year2 = cal.get(Calendar.YEAR);
int weekday2 = cal.get(Calendar.DAY_OF_WEEK);
GregorianCalendar birthday = new GregorianCalendar(1994, Calendar.JANUARY, 1);
int dayOfMonth3 = birthday.get(Calendar.DAY_OF_MONTH);
int month3 = birthday.get(Calendar.MONTH);
int year3 = birthday.get(Calendar.YEAR);
int weekday3 = birthday.get(Calendar.DAY_OF_WEEK);
birthday.add(Calendar.DAY_OF_MONTH, 10000);
int weekday4 = birthday.get(Calendar.DAY_OF_WEEK);
int dayOfMonth4 = birthday.get(Calendar.DAY_OF_MONTH);
int month4 = birthday.get(Calendar.MONTH);
int year4 = birthday.get(Calendar.YEAR);
System.out.printf("Todays date is " +month + "/" +dayOfMonth +"/" +year +".");
System.out.printf(" It is day " +weekday +" of the week");
System.out.println("");
System.out.printf("In 100 days it will be " +month2 + "/" +dayOfMonth2 +"/" +year2 +". ");
System.out.printf("Day " +weekday2 +" of the week");
System.out.println("");
System.out.printf("My Birthday is " +month3 + "/" +dayOfMonth3 +"/" +year3 +". "+"Day " +weekday3 +" of the week");
System.out.println("");
System.out.printf("10,000 days after my birthday is " +month4 + "/" +dayOfMonth4 +"/" +year4 +". " +"Day " +weekday4 +" of the week");
そのため、今日の日付、100日後の日付、誕生日の日付、および誕生日の1万日後の月を修正するためのサポートが必要です。どんな助けや洞察も大歓迎です。