ここでの永続的なカレンダーの制作は、主にカレンダークラスとグレゴリアンカレンダークラスを使用しています。まず基本を確認しましょう。
基本部品
1。カレンダークラス。
1。メインフィールド:
年(年)、月(月は0から始まります)、日付(1月の日)、時間(朝または午後の時間を示します)、hour_f_day(その日の時間を示します。)、day_of_week(週の数を示します)、day_of_month(年の週を示す)、day_of_of_year月の週数)、week_of_year(年の週数を示します)
2。カレンダークラスオブジェクトを取得します。
//カレンダークラスの静的メソッドの取得を取得します。カレンダーca = charend.getInstance();
3。主な方法
void set(int field、int value)//年月日の日付など、フィールドカレンダークラスのパラメーター.... void set(int year、int month、int date)//セット年、月、日。 void set(int year、int month、int date、int hourofday、int minute)// set year、month、day、and minute) int get(int field)//指定されたカレンダーフィールドの値を返します。例:int month = acobj.get(calendar.month); date gettime()//カレンダー時間値を表す日付オブジェクトを返します。 long getTimeInmillis()// 1970.1.1 00:00:00からカレンダーにミリ秒数を返します。 void add(int field、amont); //カレンダールールに従って、指定されたカレンダーフィールドの指定された時間を追加または減算します。追加または差し引くことができます。例:Caobj.Add(Calendar.Month、1)来月。
2。グレゴリアンカレンダークラス。
1.このクラスオブジェクトを取得します
カレンダーCA =新しいGregorianCalendar()//デフォルトの現在のモーメント。カレンダーCA =新しいGregorianCanlendar(int year、int month、int dayofmonth)//最初は、指定された年、月、日を持つグレゴリオのクラスオブジェクトです。カレンダーCA =新しいGregorianCanlendar(int year、int month、int dayofmonth、int hourofday、int minute)グレゴリオクラスのオブジェクトは、最初に指定された年、月、日を持っています。カレンダーCA =新しいGregorianCanlendar(int year、int month、int dayofmonth、int hourofday、int hours、int second)//最初は、指定された年、月、日を持つグレゴリオのクラスオブジェクトです。上記はすべて、デフォルトのロケールとデフォルトのタイムゾーンオブジェクトを取得することにより取得されます。
2。使用法の使用は、主に親クラスカレンダーを継承します。
セクションの例
3。永久カレンダーコード
パッケージcom.via.mce.monthcalendar.utils; Import java.util.calendar; Import java.util.date; Import java.util.gregoriancalendar; Import java.util.hashmap;/*** lunarカレンダー。 <br> * 1901年から2100年の月の間の年、月、太陽の項のサイズを節約し、これらのデータに基づいて計算します。 <br> * <br> *月カレンダーのいくつかの定数属性フィールドが追加されており、get()メソッドを使用して、カレンダーの対応する値を取得できます。 <br> *月の暦年、月、および日は、set()/add()/roll()メソッドを使用して設定することもでき、その他の月カレンダー属性は自動的に計算されます。 <br> *さらに、getchinese(int field)メソッドも、月カレンダーの中国のテキストを取得するために提供されています(月のカレンダー属性と週のみに適用されます)。 <br> * <ul> * <li>中国語 - lunar年</li> * <li>中国語-month -lunar month </li> * <li>中国語</li> * <li>中国語_sectional_term -solar emply of the Month </li> * <li> chinese_principly_termty月の年の茎</li> * <li>中国語_earthly_branch-月の年の地上の枝</li> * <li>中国のゾディアック - 月の年の星帯それ以外の場合、その日が1日の最初の日である場合、月の月を示します。そうしないと、月の日を示します。 * </ul> *注:<br> *カレンダークラスの設定により、グレゴリオ月は0から始まります。すべての方法はこの規則に従います。 <br> *しかし、すべての月の属性は1から始まります。カレンダーで提供された方法でも、月の月は1で始まり、負の数の跳躍月を表します。 <br> * clear()メソッドは月のカレンダーを引き起こし、グレゴリオカレンダーの日付が一貫性がないか、予想されるリセット効果を達成できません。可能な限り避けるべきです。 <br> * getsimpledatestring()を使用してグレゴリオカレンダーの日付文字列を取得すると、グレゴリオ暦月が修正されました。 <br> * getsimplechinesedatestring()を使用して月のカレンダー日付文字列を取得する場合、月の跳躍月は *で表されます。 <br> * * @version 0.12 2011-9-5 <br> * <blockquote>月カレンダーの最初の月を使用してカレンダーを初期化するときにカレンダーがデッドサイクルに閉じ込められた問題を修正しました。 </blockquote> * @version 0.11 2009-12-27 <br> * <blockquote>中国の月カレンダーを取得したときに月カレンダーが計算されなかった問題を修正しました。 <br> *デスクカレンダーのディスプレイ方法を模倣するために、フィールド中国語のdisple式メソッドを模倣するフィールドを追加します。その日に太陽の用語がある場合、太陽項が月の月の最初の日である場合、それ以外の場合は月の日を示します。 </blockquote> * @version 0.10 2009-12-22 */public final class chinesecalendarはグレゴリアンカレンダー{private static final long serialversionuid = 8l; / ** lunar year*/ public static final int hisshen_year = 801; / ** lunar month*/ public static final int hisshin_month = 802; / ** lunar day*/ public static final int hishine_date = 803; / **月の太陽項(以前の太陽項)に対応するグレゴリオの日*/ public static final int hishnos_sectional_term = 804; / **月の太陽項に対応するグレゴリオの日(次の太陽項) / **天国の茎*/ public static final int hishine_heavenly_stem = 806; / ** Earthly Branches*/ public static final int hishnos_earthly_branch = 807; / ** Zodiac Signs(Zodiac Signs)*/ public static final int hishnos_zodiac = 808; / **太陽項または月の日*/ public static final int hishnow_term_or_date = 888; // Skywangによる追加/ **ソーラーターム*/ public static final int solar_festival = 810; / **ソーラーターム*/ public static final int hisshen_term = 811; / **月または月の日*/ public static final int hishnos_month_or_date = 812; / **フェスティバルまたはソーラー用語または月の日*/ public static final int festival_or_term_or_date = 813; Private Int Chisshinyear; Private Int Chinesemonth; // 1から始めます。負の数は跳躍月を表します。プライベートINTセクション; //グレゴリオデイプライベートイントプリンシップレーム。 //グレゴリオデイプライベートブールアレンは中国のフィールドが競合しています。 //月の日付が計算され、プライベートブールのaresolartermsがコンプットしたことを確認したかどうか。 //太陽項が計算され、プライベートブールのlastSetchineseを確認したかどうか。 //月の属性の最後の設定/**現在の時刻を使用してインスタンスを構築します。 */ public chinesecalendar(){super(); } /**指定された時間を使用してインスタンスを構築します。 */ public chinesecalendar(日付d){super.settime(d); } /**指定された時間を使用してインスタンスを構築します。 */ public chinesecalendar(カレンダーc){this(c.gettime()); } /**指定されたグレゴリオの日付を使用してインスタンスを構築します。 */ public chinesecalendar(int y、int m、int d){super(y、m、d); } /***指定された日付でインスタンスを作成します。 * * @param ischinese *それは月の日付 * @param y * @param m * @param d */ public chinesecalendar(boolean ischinese、int y、int m、int d){if(ischinese){set(hishine_year、y); set(chish_month、m); set(hisshen_date、d); } else {set(y、m、d); }} public void set(int field、int value){computeifneed(field); if(Ischinesefield(field)){// lunar Calendar Attribute switch(field){case inseren_year:chishyear = value;壊す; case essine_month:chinesemonth = value;壊す; case shinen_date:chinesedate = value;壊す;デフォルト:新しいIllegalargumentException( "サポートされていないフィールド設定:" +フィールド); } lastsetchinese = true; } else {//非lunarカレンダー属性super.set(field、value); lastsetchinese = false; } arefieldsset = false; arechinesefieldscomputed = false; aresolartermscomputed = false; } public int get(int field){computeifneed(field); if(!ischinesefield(field)){return super.get(field); } switch(field){case inseren_year:return mishnyyear;ケースチャイナ_month:Chinesemonthを返します。ケースチャイナ_date:Chinesedateを返します。 CASE shinese_sectional_term:return sectionalterm; Case inseren_principle_term:return principleterm; CASE sishine_heavenly_stem:return(shinenyyear -4)%10 + 1; case sishine_earthly_branch:case insish_zodiac:return(chishyear -4)%12 + 1; case中子_month_or_date:if(get(mishn_date)== 1){return inshany_month; } else {return mishne_date; } case shinen_term_or_date:int option; if(get(calendar.date)== get(bishne_sectional_term)){option = hisshen_sectional_term; } else if(get(calendar.date)== get(hisshen_principle_term)){option = hisshen_principle_term; } else if(get(hisshen_date)== 1){option = chish_month; } else {option = hisshen_date; } return option;デフォルト:新しいIllegalargumentException( "サポートされていないフィールドGET:" +フィールド); }} public void add(int field、int lument){computeifneed(field); if(!ischinesefield(field)){super.add(field、rumant); lastsetchinese = false; arechinesefieldscomputed = false; aresolartermscomputed = false;戻る; } switch(field){case shinese_year:chishyear += lument;壊す; case shinese_month:for(int i = 0; i <lument; i ++){chinesemonth = nextchinesemonth(chishineyear、chinesemonth); if(chinesemonth == 1){chishyear ++; } } 壊す; case shinen_date:int maxdate = daysinchinesemonth(chishyear、chinesemonth); for(int i = 0; i <lument; i ++){chinesedate ++; if(chinesedate> maxdate){chinesedate = 1; Chinesemonth = next -chinesemonth(chishineyear、chinesemonth); if(chinesemonth == 1){chishyear ++; } maxdate = daysinchinesemonth(中国語、chinesemonth); }} default:新しいIllegalargumentException( "サポートされていないフィールド:" +フィールド); } lastsetchinese = true; arefieldsset = false; arechinesefieldscomputed = false; aresolartermscomputed = false; } public void roll(int field、int lument){computeifneed(field); if(!ischinesefield(field)){super.roll(field、lument); lastsetchinese = false; arechinesefieldscomputed = false; aresolartermscomputed = false;戻る; } switch(field){case shinese_year:chishyear += lument;壊す; case shinese_month:for(int i = 0; i <lument; i ++){chinesemonth = nextchinesemonth(chishineyear、chinesemonth); } 壊す; case shinen_date:int maxdate = daysinchinesemonth(chishyear、chinesemonth); for(int i = 0; i <lument; i ++){chinesedate ++; if(chinesedate> maxdate){chinesedate = 1; }} default:新しいIllegalargumentException( "サポートされていないフィールド:" +フィールド); } lastsetchinese = true; arefieldsset = false; arechinesefieldscomputed = false; aresolartermscomputed = false; } /***属性の中国語を取得します。使用できる属性フィールドは、day_of_weekとすべての月の属性フィールドです。 * * @param field * @return */ public string getchinese(int field){computeifneed(field); switch(field){case inseren_year:return getChinese(hisshen_heavenly_stem) + getChinese(hisshen_earthly_branch) + "year"; case shinen_month:if(chinesemonth> 0)return chinesemonthnames [chinesemonth] + "month";それ以外の場合は、「Leap」 + Chinesemonthnames [-chinesemonth] + "month"を返します。 Case shinese_date:chinesedateNames [chinesedate]を返します。 case sishen_sectional_term:return sectiontermnames [get(calendar.month)]; case shinese_principle_term:return principletermnames [get(calendar.month)]; case shinese_heavenly_stem:return semermames [get(field)]; Case shinese_earthly_branch:return branchnames [get(field)]; Case inseren_zodiac:return animalnames [get(field)];ケースカレンダー.day_of_week:return mishnisweeknames [get(field)]; case shinese_term_or_date:return getchinese(get(shinese_term_or_date)); case lunar_festival:return getlunarfestival();ケースSOLAR_FESTIVAL:return getSolarFestival(); case festival_or_term_or_date:return getFestivalorTermordate(); // TODO CASE CASE CHINES_MONTH_OR_DATE:return getChinese(get(mishn_month_or_date)); Case inseren_term:return getChinesEterm();デフォルト:新しいIllegalargumentException( "サポートされていないフィールドチャイニーズゲット:" +フィールド); }} public string getsimplegregoriandatestring(){return new StringBuffer()。append(get(year))。append( " - ").append(get(month) + 1).append( " - ")。 } public string getsimplechinesedAtestring(){return new Stringbuffer().append(get(hisshen_year)).append(get(hisshin_month)> 0? "" + get(chiss_month): " +" +(-get(chiss_month))): " } public string getChinesedAtestring(){return new StringBuffer()。append(getchinese(hisshen_year)).append(getchinese(hisshen_month)).append(getchinese(hisshen_date))。tostring(); } public string toString(){stringbuffer buf = new StringBuffer(); buf.append(getsimplegregoriandatestring())。append( "|").append(getchinese(day_of_week))。 .append(get(shinese_sectional_term))。append( "day").append(getchinese(hisshen_sectional_term))。 return buf.tostring(); } / ** *それが月の属性であるかどうかを判断します * * @param field * @return * / private boolean ischinesefield(int field){switch(field){case esseny_year:case inseren_month:case inseren_date:case shinese_sectional_term:case shinese_principle_ter中国語_term_or_date:case inseren_month_or_date:return true;デフォルト:falseを返します。 }} / ** *それが太陽項に関連する属性であるかどうかを判断します * * @return * / private boolean ischineseTermsfield(int field){switch(field){case shinese_sectional_term:case shinese_principle_term:case shinese_term_or_date:return true;デフォルト:falseを返します。 }} /** *前回設定された属性が今回設定または取得するものと同じではない場合(月のカレンダー /グレゴリアンカレンダー)、<br> *たとえば、最後に設定したときは、グレゴリアンカレンダーを設定または取得したいと思います。 * * @param field */ private void computeifneed(int field){if(ischinesefield(field)){if(!lastsetchinese &&!arechinesefieldscomputed){super.complete(); Computechinesefields(); arefieldsset = true; arechinesefieldscomputed = true; aresolartermscomputed = false; } if(ischinesEtermsfield(field)&&!aresolartermscomputed){computesolarterms(); aresolartermscomputed = true; }} else {if(lastsetchinese &&!arefieldsset){computegregorianfields(); super.complete(); arefieldsset = true; arechinesefieldscomputed = true; aresolartermscomputed = false; }}} / ***月日付を使用してgregoriandateを計算します* / private void computegregorianfields(){int y = chissyear; int m = chinesemonth; int d = chinesedate; arechinesefieldscomputed = true; arefieldsset = true; lastsetchinese = false; //日付範囲を調整します(y <1900)y = 1899; else if(y> 2100)y = 2101; if(m <-12)m = -12; else if(m> 12)m = 12; if(d <1)d = 1; else if(d> 30)d = 30; int dateint = y * 10000 + math.abs(m) * 100 + d; if(dateint <19001111){//小さすぎるセット(1901、calendar.january、1); super.complete(); } else if(dateint> 21001201){//大きすぎるセット(2100、Calendar.December、31); super.complete(); } else {if(math.abs(m)> 12){m = 12; } int days = chinesecalendar.daysinchinesemonth(y、m); if(days == 0){m = -m; days = chinesecalendar.daysinchinesemonth(y、m); } if(d> days){d = days; } set(y、math.abs(m)-1、d); Computechinesefields(); int on rument = 0; while(中国語!= y || chinesemonth!= m){lument += daysinchinesemonth(chishiney、chinesemonth); Chinesemonth = next -chinesemonth(chishineyear、chinesemonth); if(chinesemonth == 1){chishyear ++; }} rument += d -chinesedate; super.add(calendar.date、rument); } computechinesefields(); } / ***グレゴリオの日付を使用して月のカレンダーの日付を計算します* / private void Computechinesefields(){int gregorianyear = internalget(calendar.year); int gregorianmonth = internalget(calendar.month) + 1; int gregoriandate = internalget(calendar.date); if(gregorianyear <1901 || gregorianyear> 2100){return; } int startyear、startmonth、startdate; if(gregorianyear <2000){startyear = baseyear; startmonth = basemonth; startdate = beasedate;中国語= basechineseyear; Chinesemonth = Basechinesemonth; Chinesedate = Basechinesedate; } else {// 2番目の対応する日は、コンピューティング効率を改善するために使用されます// 2000年1月1日、対応する月カレンダー4697(1999)、startyear = baseyear + 99; startmonth = 1; startdate = 1;中国語= basechineseyear + 99; Chinesemonth = 11; Chinesedate = 25; } int daysdiff = 0; //年for(int i = startyear; i <gregorianyear; i ++){if(isgregorianLeapyear(i)){daysdiff+= 366; // leap year} else {daysdiff += 365; }} //月の月(int i = startmonth; i <gregorianmonth; i ++){daysdiff+= dayingregorianmonth(gregorianyear、i -1); } // daydaysdiff += gregoriandate -startdate; Chinesedate += daysdiff; int lastdate = daysinchinesemonth(中国語、chinesemonth); while(chinesedate> lastdate){chinesedate- = lastdate; Chinesemonth = next -chinesemonth(chishineyear、chinesemonth); if(chinesemonth == 1){chishyear ++; } lastdate = daysinchinesemonth(中国語、chinesemonth); }} / ***ソーラー項を計算* / private void computesolarterms(){int gregorianyear = internalget(calendar.year); int gregorianmonth = internalget(calendar.month); if(gregorianyear <1901 || gregorianyear> 2100){return; } sectionalterm = sectionalterm(gregorianyear、gregorianmonth); Principleterm = frictionterm(gregorianyear、gregorianmonth); } / *次は静的方法です〜 * / / ** *それはグレゴリオ年の跳躍年 * * @param year * @return * / public static boolean isgregorianleapyear(int year){boolean isleap = false; if(year%4 == 0){isLeap = true; } if(year%100 == 0){isLeap = false; } if(year%400 == 0){isLeap = true; } ISLEAPを返します。 } /***グレゴリオ年の日数を計算し、グレゴリオ月は0から始まります! * * @param y * @param m * @return */ public static int daysingregorianmonth(int y、int m){int d = dayingregorianmonth [m]; if(m == calendar.february && isgregorianLeapyear(y)){d ++; //グレゴリオ年の跳躍年のもう1日の日}戻りますd; } /***グレゴリオ月の太陽項を計算すると、グレゴリオ月は0から始まります! * * @param y * @param m * @return */ public static int cectionalterm(int y、int m){m ++; if(y <1901 || y> 2100){return 0; } int index = 0; int ry = y -baseyear + 1; while(ry> = sectionaltermyear [m -1] [index]){index ++; } intターム= sectionaltermmap [m -1] [4 * index + ry%4]; if((ry == 121)&&(m == 4)){term = 5; } if((ry == 132)&&(m == 4)){term = 5; } if((ry == 194)&&(m == 6)){term = 6; } return term; } /***グレゴリオ年のZhongqiを計算し、グレゴリオ月は0から始まります! * * @param y * @param m * @return */ public static int principleterm(int y、int m){m ++; if(y <1901 || y> 2100){return 0; } int index = 0; int ry = y -baseyear + 1; while(ry> = principletermyear [m -1] [index]){index ++; } intターム= spinitalmemmap [m -1] [4 * index + ry%4]; if((ry == 171)&&(m == 3)){Term = 21; } if((ry == 181)&&(m == 5)){term = 21; } return term; } / ** *月の年の日数を計算 * * @param y * @param m * @return * / public static int daysinchinesemonth(int y、int m){//注:leap month m <0 int index = y -basechineear + baseindex; int v = 0; int l = 0; int d = 30; if(1 <= m && m <= 8){v = chinesemonths [2 * index]; l = m -1; if(((v >> l)&0x01)== 1){d = 29; }} else if(9 <= m && m <= 12){v = chinesemonths [2 * index + 1]; l = m -9; if(((v >> l)&0x01)== 1){d = 29; }} else {v = chinesemonths [2 * index + 1]; v =(v >> 4)&0x0f; if(v!= math.abs(m)){d = 0; } else {d = 29; for(int i = 0; i <bigleapmonthyears.length; i ++){if(bigleapmonthyears [i] == index){d = 30;壊す; }}}} return d; } / ** * lunarカレンダーの次の月を計算 * * @param y * @param m * @return * / public static int nextchinesemonth(int y、int m){int n = math.abs(m) + 1; if(m> 0){int index = y -basechineseyear + baseindex; int v = chinesemonths [2 * index + 1]; v =(v >> 4)&0x0f; if(v == m){n = -m; }} if(n == 13){n = 1; } return n; } /*カレンダーの最初の日の日付* / private static final int baseyear = 1901;プライベート静的最終int basemonth = 1; private static final int basedate = 1;プライベート静的final int baseindex = 0; Private static final int basechineyear = 1900; Private Static Final int basechinesemonth = 11; Private Static Final Int Basechinesedate = 11; /*中国文字列*/ private static final string [] shinenweeknames = {"" "、"日曜日 "、「月曜日」、「火曜日」、「木曜日」、「金曜日」、「土曜日」}; private static final string [] chinesemonthnames = {"" "、" first "、" 3 "、" 4 "、" 5 "、" 6 "、" 7 "、" 8 "、" nine "、" 10 "、" 10、 "、"、 "twelve"}; private static final string [] chinesedatenames = {"" "" "first"、 "first"、 "fourth"、 "5"、 "sixth"、 "7"、 "eighth"、 "nine"、 "nine"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth" "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"、 "tenth"};プライベート静的な最終文字列[] PrincipleTermNames = {「グレートコールド」、「雨水」、「スプリングエクイノックス」、「緑の雨」、「夏の太陽夏」、「グリーンサマー」、「グリーンサマー」、「グリーンサマー」、「グリーンサマー」、「サマーソーラー」、「グリーンサマー」、「星空夏」、「星空夏」、「9月equinox」、「frost fall ""プライベート静的な最終文字列[] sectiontermnames = {"Little Cold"、 "Bird Spring"、 "Jingzhe"、 "Qingming"、 "summer of Summer of Summer"、 "Graining Seeds"、 "Little heat"、 "Bird autumn"、 "White Dew"、 "Cold Dew"、 "Breaking Winter"、 "High Snow"; private static final string [] semnames = {"" "、" jia "、" yi "、" bing "、" ding "、" wu "、" ji "、" geng "、" xin "、" ren "、" gui "}; private static final string [] branchnames = {"" "" "zi"、 "ug"、 "yin"、 "mao"、 "chen"、 "si"、 "wu"、 "shen"、 "you"、 "xu"、 "hai"};プライベート静的な最終文字列= {"" "" "" "" "" "rat"、 "ox"、 "tiger"、 "rabbit"、 "dragon"、 "snake"、 "馬"、 "羊"、 "猿"、 "犬"、 "豚"}; / *次はデータ圧縮テーブル〜 */ private static final int [] bigleapmonthyears = {6、14、19、25、33、36、38、41、44、52、55、79、117、136、147、150、155、158、185、193}; private static final char[][] sectionalTermMap = { { 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5 }, { 5, 4, 5, 5, 5, 4, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 3, 3, 4, 4, 3, 3, 3 }, { 6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5 }, { 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 4, 4, 5, 5, 4, 4, 4, 5, 4, 4, 4, 4, 5 }, { 6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5 }, { 6, 6, 7, 7, 6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5 }, { 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 6, 6, 6, 7, 7 }, { 8, 8, 8, 9, 8, 8, 8, 8、7、8、8、8、8、7、7、8、8、7、7、7、8、7、7、7、7、7、7、7、7、7、7、6、6、7、7、7、7、7}、{8、8、8、8、9、8、8、8、8、8、8、8、8、8、8、8、8、7、7、8、8、8、7、7、8、8、7、7、7、7、7、7、7、7、7、7、7、7、7、7、7、7、7、7、7、7 9, 9, 9, 9, 8, 9, 9, 9, 8, 8, 9, 9, 8, 8, 8, 9, 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 8 }, { 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 7}、{7、8、8、8、8、7、7、8、8、7、7、7、8、7、7、7、7、6、7、7、7、6、6、7、7、6、6、6、7、7}}};プライベート静的最終char [] [] sectionaltermyear = {{13、49、85、117、149、185、201、250、250}、{13、45、81、117、149、185、250}、{13、48、84、112、148、184、200、200、250、145、145、148、148、148、148、148、148、148、148、148、148、 172、200、201、250}、{13、44、72、104、132、168、200、201、250}、{5、33、68、96、124、152、188、200、201}、{29、57、85、120、148、176、250、13、48、13、48、13、48、13、48、13、48、13、48、13、48、13、48、13、48、13、48、13、48、13、48、13、48、 200、201}、{25、60、88、120、148、184、200、201、250}、{16、44、76、108、144、172、200、201、250}、{28、60、92、124、160、192、200、201、250}、{17、53、85、124、156、188、188、250、188、250、188、188、250、188、250、188、250、188、250、188、250、188、188プライベートスタティックファイナルチャー[] [] [] PrincipletermMap = {{21、21、21、21、21、21、20、21、21、20、20、21、21、20、20、20、20、20、20、20、19、20、20、20、19、20}、{20、19、19、20、20、19、19、19、19、19、19、19、19、19、19、19、19、19、19、19、19、19、 19, 19, 18, 18, 18, 18, 18, 18, 18 }, { 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 21, 20, 20, 20, 20, 19, 20, 20, 20, 20 }, { 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 21, 20, 20, 20, 20, 19, 20, 20, 20, 19, 19, 20, 20, 19, 19, 19, 20, 20 }, { 21, 22, 22, 22, 21, 21, 22, 22, 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 21, 21 }, { 22, 22, 22, 22, 21, 22, 22, 22, 21, 21, 22, 22, 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 21 }, { 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, 23, 22, 22, 22, 22, 23 }, { 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, 23, 23 }, { 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, 23, 23 }, { 24, 24, 24, 24, 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 23 }, { 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, 23, 22, 22, 22, 22, 21, 22, 22, 22, 21, 21, 22, 22, 22 }, { 22, 22, 23, 23, 22, 22、22、23、22、22、22、22、21、22、22、22、21、21、22、22、21、21、22、21、21、21、21、22}}}; Private Static Final Char [] [] [] [] Principletermyear = {{13、45、81、113、149、185、201}、{21、57、93、125、161、193、201}、{21、56、88、120、152、188、200、201}、{21、49、81、116、176、176、176、176、176、176、176、176、176、176、176 49、201}、{28、60、88、116、148、180、200、201}、{25、53、84、112、144、172、200、201}、{29、57、89、120、148、180、200、201}、{17、45、73、73、108、140、168、20、20、20、20、20、20、20、20、20、20、20、20、20、20、20、20、20、20、20、20、 124、160、192、200、201}、{16、44、80、112、148、180、200、201}、{17、53、88、120、156、188、200、201}}; Private static final char [] DayingRegorianMonth = {31、28、31、30、31、30、31、31、30、31};プライベートスタティックファイナルチャー[] Chinesemonths = {0x00、0x04、0xad、0x08、0x5a、0x01、0xd5、0x54、0xb4、0x09、0x64、0x05、0x59、0x45、0x95、0x95、0x95、0x0a、0x24、0x24、0x245555555555555555555555555、 0xad、0x08、0x5a、0x62、0xda、0x04、0xb4、0x05、0xb4、0x55、0x52、0x0d、0x94、0x0a、0x4a、0x2a、0x56、0x02、0x6d、0x71、0x6d、0x6d、0x6d、0x6d、 0x02、0xd2、0x52、0xa9、0x05、0x49、0x0d、0x2a、0x45、0x2b、0x09、0x56、0x01、0xb5、0x20、0x6d、0x01、0x59、0x69、0x69、0xd4、0x05、0x05、0x05、0x05、0x05 0xa9、0x56、0xa5、0x04、0x2b、0x09、0x9e、0x38、0xb6、0x08、0xec、0x74、0x6c、0x05、0xd4、0x0a、0xe4、0x6a、0x52、0x52、0x05、0x95、0x95、0x95、0x95、0x95、0x95、0x95 0x42、0x5b、0x04、0xb6、0x04、0xb4、0x22、0x6a、0x05、0x52、0x75、0xc9、0x0a、0x52、0x05、0x35、0x55、0x4d、0x0a、0x5a、0x5a、0x31d、0x31d、0x3 0xb5、0x02、0x6a、0x8a、0x68、0x05、0xa9、0x0a、0x8a、0x6a、0x2a、0x05、0x2d、0x09、0xaa、0x48、0x5a、0x01、0xb5、0xb5、0x09、0x639、0x639、0x639 0x05、0x25、0x75、0x95、0x0a、0x96、0x04、0x4d、0x54、0xad、0x04、0xda、0x04、0xd4、0x44、0xb4、0x05、0x54、0x85、0x52、0x0d、0x0d、0x0d、0x0d、0x0 0x56、0x6a、0x56、0x02、0x6a、0x41、0xda、0x02、0xb2、0xa1、0xa9、0x05、0x49、0x0d、0x0a、0x6d、0x2a、0x09、0x56、0x56、0x01、0x01d、0x0、0x0、 0xd9、0x02、0xd1、0x3a、0xa8、0x05、0x29、0x85、0xa5、0x0c、0x2a、0x09、0x96、0x54、0xb6、0x08、0x6c、0x09、0x64、0x64、0x45、0xd4、 0x05、0x51、0x25、0x95、0x0a、0x2a、0x72、0x5b、0x04、0xb6、0x04、0xac、0x52、0x6a、0x05、0xd2、0x0a、0xa2、0x4a、0x4a、0x4a、0x05、0x05、0x055、0x94 0x2d、0x0a、0x5a、0x02、0x75、0x61、0xb5、0x02、0x6a、0x03、0x61、0x45、0xa9、0x0a、0x4a、0x05、0x25、0x2d、0x09、0x9a、0x9a、0x08、0x08、0x08、 0xb4、0x09、0xa8、0x59、0x54、0x03、0xa5、0x0a、0x91、0x3a、0x96、0x04、0xad、0xb0、0xad、0x04、0xda、0x04、0xf4、0x62、0xb4、0x05、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0xb4、0 0x44、0x5d、0x52、0x0a、0x95、0x04、0x55、0x22、0x6d、0x02、0x5a、0x71、0xda、0x02、0xaa、0x05、0xb2、0x55、0x49、0x49、0x0b、0x2、0x2、0x2 0x39、0x36、0x01、0x6d、0x80、0x6d、0x01、0xd9、0x02、0xe9、0x6a、0xa8、0x05、0x29、0x0b、0x9a、0x4c、0xaa 0x6c、0x09、0x54、0x75、0xd4、0x0a、0xa4、0x05、0x45、0x55、0x95、0x0a、0x9a、0x04、0x55、0x44、0xb5、0x04、0x6a、0x6a、0x82、0xd2、0x6a 0x0a、0x92、0x6a、0x4a、0x05、0x55、0x0a、0x2a、0x4a、0x5a、0x02、0xb5、0x02、0x31、0x69、0x31、0x73、0xa9、0x0a、0x4a、0x4a、0x4a、0x05、0x05、0x2d 0x2d、0x09、0x5a、0x01、0xd5、0x48、0xb4、0x09、0x68、0x89、0x54、0x0b、0xa4、0x0a、0xa5、0x6a、0x95、0x04、0xad、0x08、0x6a、0x6a、0x6a、0x6a、0x6a 0x04、0x74、0x05、0xb0、0x25、0x54、0x03}; private string getChinesEterm(){if(get(calendar.date)== get(binush_sectional_term)){return sectionaltermnames [get(calendar.month)]; } else if(get(calendar.date)== get(hisshen_principle_term)){return principletermnames [get(calendar.month)]; } else nullを返します。 } // skywang by skywang private string getlunarfestival(){int day = get(hissh_date); int month = get(chish_month); string stoday = day <10? "0" + day: "" + day; string smonth =月<10? "0"+(month): "+(month); return lfestival.get(smonth+stoday);} private string getsolarfestival(){int day = get(calendar.date); int month = get(calendar.month); string stoday = day <10?" 0 "+day:" "+day; string smonth = month <10?"+1) "+1) return sfestival.get(Smonth+Stoday); } private string getFestivalorTermordate(){string ret; if((ret = getsolarfestival())!= null)returt ret; if((ret = getlunarfestival())!= null)returt ret; getchineseを返します(get(hisshen_term_or_date)); } //グレゴリアンフェスティバルプライベート静的ハッシュマップ<string、string> sfestival = new hashmap <string、string>(); // lunar intervene private private static hashmap <string、string> lfestival = new hashmap <string、string>(); static {sfestival.put( "0101"、 "新年の日"); sfestival.put( "0214"、 "Valenteen Day"); sfestival.put( "0308"、 "女性の日"); sfestival.put( "0312"、 "アーバーデイ"); sfestival.put( "0401"、 "4月の日"); sfestival.put( "0501"、 "労働者の日"); sfestival.put( "0504"、 "Youth Day"); sfestival.put( "0601"、 "Children's Day"); sfestival.put( "0701"、 "センターデイ"); sfestival.put( "0801"、 "Army Day"); sfestival.put( "0910"、 "教師の日"); sfestival.put( "1001"、 "National Day"); sFestival.put("1031","Halloween"); // sFestival.put("1112","Birthday of Sun Yat-sen"); sFestival.put("1225","Christmas"); lFestival.put("0101","Spring Festival"); // lFestival.put("0102","Quan 2"); // lFestival.put("0103","Quan 3"); lFestival.put("0115","Lantern Festival"); lFestival.put("0505","Dragon Boat Festival"); lFestival.put("0707","Qianxi Festival"); lFestival.put("0815","Mid-Autumn Festival"); lFestival.put("0909","Dongyang Festival"); lFestival.put("1208","Laba Festival"); // lFestival.put("1299","New Year's Eve"); }}