嶄忽滴煽麻隈java糞?
扮寂:2010-12-29
/**
* 嶄忽滴煽麻隈 - 糞喘噐巷煽 1901 定崛 2100 定岻寂議 200 定
*/
import java.text.*;
import java.util.*;
class ChineseCalendarGB {
private int gregorianYear;
private int gregorianMonth;
private int gregorianDate;
private boolean isGregorianLeap;
private int dayOfYear;
private int dayOfWeek; // 巓晩匯佛豚議及匯爺
private int chineseYear;
private int chineseMonth; // 減方燕幣避埖
private int chineseDate;
private int sectionalTerm;
private int principleTerm;
private static char[] daysInGregorianMonth =
{31,28,31,30,31,30,31,31,30,31,30,31};
private static String[] stemNames =
{"遮","厰","央","供","隷","失","口","仭","班","刻"};
private static String[] branchNames =
{"徨","鞄","咥","樽","浬","鉾","怜","隆","賦","嗜","伜","坤"};
private static String[] animalNames =
{"報","釘","拶","傭","霜","敷","瀧","剪","削","痔","昂","幎"};
public static void main(String[] arg) {
ChineseCalendarGB c = new ChineseCalendarGB();
String cmd = "day";
int y = 1901;
int m = 1;
int d = 1;
if (arg.length>0) cmd = arg[0];
if (arg.length>1) y = Integer.parseInt(arg[1]);
if (arg.length>2) m = Integer.parseInt(arg[2]);
if (arg.length>3) d = Integer.parseInt(arg[3]);
c.setGregorian(y,m,d);
c.computeChineseFields();
c.computeSolarTerms();
if (cmd.equalsIgnoreCase("year")) {
String[] t = c.getYearTable();
for (int i=0; i<t.length; i++) System.out.println(t[i]);
} else if (cmd.equalsIgnoreCase("month")) {
String[] t = c.getMonthTable();
for (int i=0; i<t.length; i++) System.out.println(t[i]);
} else {
System.out.println(c.toString());
}
}
public ChineseCalendarGB() {
setGregorian(1901,1,1);
}
public void setGregorian(int y, int m, int d) {
gregorianYear = y;
gregorianMonth = m;
gregorianDate = d;
isGregorianLeap = isGregorianLeapYear(y);
dayOfYear = dayOfYear(y,m,d);
dayOfWeek = dayOfWeek(y,m,d);
chineseYear = 0;
|