网站建设方案实例,怎样在外贸网站做业务,手机老是下载一些做任务的网站,城市门户网站策划书实现当前日历的打印#xff0c;当前日期用*来表示。关键得出这个月的第一天是星期几。基姆拉尔森计算公式W (d2*m3*(m1)/5yy/4-y/100y/400) mod 7在公式中d表示日期中的日数1#xff0c;m表示月份数。y表示年数。注意1#xff1a;在公式中有个与其它公式不同的地方#xff…实现当前日历的打印当前日期用*来表示。关键得出这个月的第一天是星期几。基姆拉尔森计算公式W (d2*m3*(m1)/5yy/4-y/100y/400) mod 7在公式中d表示日期中的日数1m表示月份数。y表示年数。注意1在公式中有个与其它公式不同的地方把一月和二月看成是上一年的十三月和十四月例假设是2004-1-10则换算成2003-13-10来代入公式计算。注意2在大多数天主教国家的日历中在1752年没有9.3-9.13。在这一年的日历中9月2号后面直接就是9月14号所以在计算某天是星期几的算法中要把这一特殊情况考虑在内package work_0529;import java.util.Scanner;public class main {private static int year;private static int month;private static int day;private static boolean flag;private static int count;//当前月份的天数public static void main(String[] args) {if(!getInput()) return;if(!judgeData()) return;int a getData();System.out.println(日 一 二 三 四 五 六);int j0;while(a-- 0){ System.out.print( ); j;}for(int i1;i count; i){if(j%70)System.out.println(\n);j;System.out.print(String.format(%4d,i));if(dayi)System.out.print(*);}}private static boolean judgeData() {flagfalse;// false表示平年。反之if(year%1000) flagtrue;else if(year%40) flagtrue;if(year0){System.out.println(年份不能小于等于0);return false;}if(month0 || month12){System.out.println(检查月份的范围);return false;}if(month2){if(flag day29){System.out.println(当前为(flag?闰年:平年)二月份不能大于29);return false;}if(!flag day 28){System.out.println(当前为(flag?闰年:平年)二月份不能大于28);return false;}if(flag) count29;else count28;}if(month1 || month3 || month5|| month7|| month8|| month10|| month12){if(day0 || day 31){System.out.println(检查日期的范围);return false;}count 31;}else if(month!2){if(day0 || day30){System.out.println(检查日期的范围);return false;}count 30;}return true;}private static int getData() {int tmpDay1;// 表示int a;if (month 1 || month 2) { month 12; year--; }if((year1752) || (year1752 month9) ||(year1752 month9 tmpDay3)){a (tmpDay 2*month 3*(month1)/5 year year/4 5) % 7;}else{a (tmpDay 2*month 3*(month1)/5 year year/4 - year/100 year/400)%7;}return a;}private static boolean getInput() {try {System.out.print(请输入日期(格式XXXX-XX-XX));Scanner scanner new Scanner(System.in);String str scanner.nextLine();year Integer.parseInt(str.substring(0, str.indexOf(-)));str str.substring(str.indexOf(-) 1, str.length());month Integer.parseInt(str.substring(0, str.indexOf(-)));str str.substring(str.indexOf(-) 1, str.length());day Integer.parseInt(str);return true;} catch (NumberFormatException e) {System.out.println(格式错误);} catch (StringIndexOutOfBoundsException e2) {System.out.println(格式错误);}return false;}}