Traditional Culture Encyclopedia - The 24 Solar Terms - Solar terms calculation code
Solar terms calculation code
Import java.util. *; /* * The rule/appendix /f2.htm here exceeds the number of words. Let me indent and delete */public solar terms {public static void main (string [] s) throwsexception {solar terms st = new solar terms (); if(s . length = = 3){ system . out . println(ST . getsoralterm(integer . parse int(s[0])),Integer.parseInt(s[ 1]),integer . parse int(s[2])); } system . out . println(ST . getsoralterm(2009, 1,5)); system . out . println(ST . getsoralterm(2009, 1,20)); system . out . println(ST . getsoralterm(2009, 1,23)); system . out . println(ST . getsoralterm(2009,2, 18)); } final static long [] terminfo = new long [] {0,21208,42467,63836,85337, 1070 14, 128867,/kloc. 173 149, 195558 private static final string [] solar $ TERM = new string [] {"slight cold", "severe cold", "beginning of spring", "rain", "shock", "vernal equinox", "Qingming", "Grain Rain", "long summer" and "xiaoman" "Summer Solstice" public SolarTerm(){}/** The core method of obtaining solar terms according to the date */public string getsoralterm (date) {calendar cal = calendar.getinstance (); Cal.setTime (date); Int y = cal.get (calendar. Year); Int m = cal.get (calendar. Month)+1; Int d = cal.get (calendar. Month day); Returns getSoralTerm(y, m, d); }/* * The core method is based on the date (Y year, M month, D day) */public string getsoralterm (int y, int m, int d) {string solar terms; if (d == sTerm(y,(m- 1)* 2))solarTerms = SolarTerm[(m- 1)* 2]; else if (d == sTerm(y,(m- 1)* 2+ 1))solarTerms = SolarTerm[(m- 1)* 2+ 1]; Else{// Here, non-solar terms = ""; } returns solar terms}/= = = What day is the nth solar term in year Y (starting from 0 slight cold)? private int stern (int y, int n) {Calendar cal = calendar.getinstance (); cal.set( 1900,0,6,2,5,0); long temp = cal.getTime()。 getTime(); Cal.setTime (new date ((long)) ((31556925974.7 * (y-1900)+terminfo [n] * 60000l)+temp)); Return to cal.get (calendar. Month day); }}
- Previous article:Understand the summer solar terms.
- Next article:Go to Qingdao on Dragon Boat Festival. What to wear?
- Related articles
- When will the green tea be picked?
- What does secondary air intake mean?
- What are the legal holidays after National Day?
- Xiaoman solar terms recommend sentences describing Xiaoman.
- Does the valve click normally?
- What's the name of diving with oxygen tanks?
- Java express
- Is it still hot after the autumnal equinox in 2020? Will the days after that get shorter?
Is it still hot after the autumnal equinox in 2020? number
The climate in the south also enters au
- When did the twenty-four solar terms in China begin?
- Excellent topic composition 600 words