大家好,今日小柳来为大家解答以上的问题。2013年的全部日历,2013年的曰历全程表很多人还不知道,现在让我们一起来看看吧!
1、看看我这个,可以一个时间段import ja.util.ArrayList;import ja.util.Calendar;import ja.util.List;public class $ {private static int[] DAYS = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };public static void main(String... _) {long l1 = System.currentTimeMillis();List data = rili(1000, 1, 10000, 12);long l2 = System.currentTimeMillis();for (int i = 0; i System.out.println(data.get(i));}System.out.println((l2 - l1) + "MS");}private static List rili(int startYear, int startMonth, int endYear, int endMonth) {if (startYear > endYear || (startYear == endYear && startMonth > endMonth)) {return null;}List data = new ArrayList();for (int ii = startYear; ii int startM = startMonth - 1;int endM = endMonth - 1;if (startYear if (ii == endYear) {endM = 11;} else {startM = 0;}}for (int i = startM; i data.add("-----------------------" + ii + "年" + (i + 1) + "月-----------------------");data.add("日t一t二t三t四t五t六");int day = days(ii, i);StringBuffer buf = new StringBuffer();int idx = 1;while (idx int len = 0;if (idx == 1) {Calendar c = Calendar.getInstance();c.set(ii, i, idx);int xingqi = c.get(Calendar.DAY_OF_WEEK);len = getLen(xingqi);buf.append(addBlank(len));}buf.append(idx++);for (int k = len + 1; k if (idx > day) {break;}buf.append("t" + (idx++));}buf.append("n");}data.add(buf);}}return data;}private static StringBuffer addBlank(int len) {StringBuffer buf = new StringBuffer();for (int index = 0; index buf.append("t");}return buf;}private static int getLen(int xingqi) {return xingqi == Calendar.SUNDAY ? 0 : xingqi - 1;}public static int days(int year, int month) {if (month != 1) {return DAYS[month];}if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {return 29;}return DAYS[month];}}如下.年可以指定.---------------------------------------------------------------------------------import ja.util.Calendar;import ja.util.Scanner;public class TestCalendar {static public void main(String 参数[]) {Calendar c = Calendar.getInstance();Scanner sc = new Scanner(System.in);System.out.println("请输入年份:");int year = sc.nextInt();c.set(Calendar.YEAR, year);c.set(Calendar.MONTH, Calendar.JANUARY);c.set(Calendar.DAY_OF_MONTH, 1);while (c.get(Calendar.YEAR) == year) {int wday = c.get(Calendar.DAY_OF_WEEK);int mday = c.get(Calendar.DAY_OF_MONTH);if (mday == 1) {System.out.println("n日t一t二t三t四t五t六t第"+ (c.get(Calendar.MONTH) + 1) + "月");System.out.println("---------------------------------------------------");for (int i = 0; i System.out.print(" t");}System.out.print(mday + "t");if (wday == 7)System.out.println();c.add(Calendar.DAY_OF_YEAR, 1);}}}。
本文到这结束,希望上面文章对大家有所帮助。
版权声明:本文内容由互联。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发 836084111@qq.com 邮箱删除。