8-character easy-to-use algorithm: using Java to build a daily Algorithm

Source: Internet
Author: User

I 've been surfing the Internet and found someone asking for an algorithm or source code on the Perpetual calendar for good or bad day/day selection. More such software charges dozens of Yuan.

I searched for articles without specific principles over the Internet for half a day.
As an easy-to-learn master (master)♂Luo Yun) has an unshirkable responsibility for telling programmers how to create the daily/daily algorithm.

Today's course is to build a daily algorithm through the 12th
This algorithm is used by many veterans.

Basic course Article: Implementation of a simple daily algorithm using Java

/** Simple implementation of the Twelve creation and selection days * @ author luozhuang master♂Luo yun*/package dayselcet; import Java. text. parseexception; import luozhuanghehun. baizirecord; /***** @ author luozhuang */public class luozhuangshierjian {/*** judge what can be done by using the 12th component. ** @ Param shierjianstring refers to the 12th component to create a string. */Public String cando = ""; public String canotdo = "";; /*** monthly daily monthly annual monthly ugly section sub-opening harvest * dangerous break hold dingping full Division construction closed ugly close open harvest dangerous break hold dingping full Division Jian Yin Jian open harvest dangerous break hold dingping full Division * Construction closed open harvest dangerous broken run dingping full Chen full Division construction closed open harvest dangerous run dingping Shouping full addition construction closed open harvest dangerous broken hold Set * Wu dingping full in addition to construction closed open harvest dangerous broken hold not executed dingping full in addition to construction closed open harvest dangerous broken Shen zhiping full in addition to the establishment, closure, and settlement * into the danger, you, the danger, the damage, the danger, the danger open ***/string [] [] DATA = {"open ", "accept", "Cheng", "dangerous", "broken", "Zhi", "ding", "ping", "full", "except", "jian ", "closed" },{ "closed", "open", "accept", "Cheng", "dangerous", "broken", "hold", "fixed ", "ping", "full", "except", ""}, {"", "closed", "open", "accept", "Cheng ", "dangerous", "broken", "Zhi", "ding", "ping", "full", "except" },{ "except", "jian ", "closed", "open", "accept", "Cheng", "dangerous", "broken", "Zhi", "ding", "ping ", "full"}, {"full", "except", "built", "closed ", "Open", "accept", "Cheng", "dangerous", "broken", "Zhi", "ding", "ping" },{ "ping ", "full", "except", "jian", "closed", "open", "accept", "Cheng", "dangerous", "broken", "hold ", "ding"}, {"ding", "ping", "full", "except", "jian", "closed", "open", "accept ", "into", "dangerous", "broken", "executive"}, {"executive", "fixed", "ping", "full", "", "jian", "closed", "open", "accept", "Cheng", "dangerous", "broken" },{ "broken", "hold ", "ding", "ping", "full", "except", "jian", "closed", "open", "accept", "Cheng ", "dangerous"}, {"dangerous", "broken", "Zhi", "ding", "ping", "full", "except", "jian ", "closed", "open", "accept", "into"}, {"into", "dangerous", "broken", "hold", "fixed ", "ping", "full", "except", "jian", "closed "," Open "," accept "},{" accept "," Cheng "," dangerous "," broken "," Zhi "," ding "," ping ", "full", "except", "", "closed", "open" },}; string [] shengxiao = {"sub", "ugly ", "Yin", "Mao", "Chen", "Si", "Wu", "wei", "shen", "you", "shen ", "Hai"}; Public String getshierjian (INT mouth, string rizhi) {If (Mouth <1 | mouth> 12) {return NULL;} int riziindex = getarrayindex (shengxiao, rizhi); return data [riziindex] [Mouth-1];} public int getarrayindex (string [] array, string targe T) {for (INT I = 0; I <array. length; I ++) {If (array [I]. equals (target) {return I;} return-1 ;} /*** building, division, full, flat, fixed, hold, broken, dangerous, success, accept, open, and closed in tongsheng 12th. Auspicious day: a day of red and white. Success: the days of success and the success of tiantiji, everything goes well. Suitable: marriage, city opening, building, earth moving, beddings, Earth breaking, burial, relocation, trading, finance seeking, travel, deed, vertical column, cutting, animal husbandry. Avoid: litigation. Harvest Day: harvest, harvest, and storage day of the Emperor's treasure house. Yi: Pray for blessings, pray for children, go to Ren, marry, settle down, build, move earth, study, Open City, trade, purchase, and lease. Avoid: debt relief, new ship launching, new car downloading, Earth breaking, burial. Opening day: Start day and start day. Yi: Sacrifice, pray, admission, take office, build, Dynamic Earth, Open City, safety bed, trade, travel, vertical column. Avoid: debt relief, litigation, and burial. The second day: the second day after the auspicious day. Day of creation: the days when all things are born, strong, and robust. Yi: Go to Ren, pray for blessings, pray for children, break earth, bury, repair, shangliang, fortune seeking, home purchasing, admission, examination, marriage, earth moving, signing, negotiation, and travel. Avoid: Dynamic Earth, warehouse opening, mining, boat taking, new ship launching, new car downloading, and water and electricity appliance maintenance. In addition to the Day: Clear the evil spirits and welcome the new days. Suitable: sacrifices, blessings, marriage, travel, group placement, relocation, shipment, earth-moving, medical seeking, and transactions. Do not: Get married, go to work, and sign contracts. Full day. Yi: Marry, pray, migrate, Open City, trade, seek wealth, submit deeds, sacrifice, travel, animal husbandry. Avoid: burial, appointment, and medical treatment. Weekdays: ordinary days. Weekdays: day on which common and common people are evenly divided. Yi: Marry, build, break earth, bury, Shepherd, Open City, bed, Earth, and children. Do not: pray, go to Ren, marry, open the city, and bury. Day: a day of stable, normal, and customized by the emperor. Yi: Sacrifice, pray, marry, build a house, renovate, build a road, open a city, enter school, take office, join a group. Avoid: litigation, travel, negotiation. Fierce day: it is not suitable for all things. It is best to avoid it. Hold the day: from the God of the broken day, said little consumption, the emperor of heaven to execute all things to God, poor days. Suitable: house building, house decoration, wedding, purchase, deed, sacrifice. Avoid: City opening, finance seeking, travel, and relocation. * Day-to-day: Day-to-month migration is not suitable for major events. Suitable for: Earth breaking, disassembling, and seeking medical treatment. Avoid: wedding, signing, negotiation, travel, and relocation. Critical days: days of crisis, danger, and unexpected events. Suitable: Sacrifice, pray, lay, disassemble, and break Earth. Do not: mountain Mount, boat trip, wedding, burial, and migration. Closing Day: the last day of building 12, closing, collecting, and closing the yin and yang of Heaven and Earth. Suitable: Sacrifice, pray, build a dike, bury a pool, bury a cave, make a funeral, fill and repair a house. Do not: Open the city, travel, seeking medical treatment, surgery, wedding. * @ Param shierjianstring wins 12 string x/Public void shierxingjianpanduan (string shierjianstring) {If (shierjianstring. equals ("") {cando + = ""; canotdo + = "";} If (shierjianstring. equals ("except") {cando + = "medication acupuncture";} If (shierjianstring. equals ("full") {cando + = ""; canotdo + = "";} If (shierjianstring. equals ("") {cando + = "tu";} If (shierjianstring. equals ("set") {cando + = "natu admission";} If (shierjianstring. equals ("") {cando + = "capture";} If (shierjianstring. equals ("broken") {cando + = "cure";} If (shierjianstring. equals ("dangerous") {cando + = "Fishing"; canotdo + = "Sailing";} If (shierjianstring. equals ("into") {cando + = "Admission"; canotdo + = "Litigation";} If (shierjianstring. equals ("") {cando + = "naocai"; canotdo + = "";} If (shierjianstring. equals ("open") {cando + = ""; canotdo + = "";} If (shierjianstring. equals ("closed") {cando + = "Bed"; canotdo + = "governance";} If (shierjianstring. equals ("") {cando + = ""; canotdo ++ = "";} If (shierjianstring. equals ("except") {cando + = "bath cleaning medication"; canotdo + = "wedding trip opening";} If (shierjianstring. equals ("full") {cando + = "wedding trip"; canotdo + = "planting and opening";} If (shierjianstring. equals ("ping") {cando + = "wedding road repair and mud coating"; canotdo + = "Planting trench opening";} If (shierjianstring. equals ("set") {cando + = "banquet protocol planting to create a wedding trip to open the ground"; canotdo + = "Cure lawsuit";} If (shierjianstring. equals ("") {cando + = "Planting capturing and building kaijing wedding"; canotdo + = "kaikai city warehouse transportation";} If (shierjianstring. equals ("") {cando + = "";} If (shierjianstring. equals ("into") {cando + = "opening school to marry Shangguan for a Tuesday trip"; canotdo + = "lawsuit";} If (shierjianstring. equals ("") {cando + = "Harvest warehouse trading school wedding creation"; canotdo + = "Travel burial acupuncture";} If (shierjianstring. equals ("") {cando + = ""; canotdo + = "";} If (shierjianstring. equals ("closed") {canotdo + = "" ;}} luozhuangjiandanxuanri my = new luozhuangjiandanxuanri (); void test (baizirecord Cal) {int intchinesemonth = Cal. lunaryue. getlunarmonth (); int intchineseday = Cal. lunaryue. getlunarday (); my. println (""); string shierjianstring = getshierjian (intchinesemonth, Cal. getganzhistring () [6]); my. println (shierjianstring); shierxingjianpanduan (shierjianstring); my. println (""); my. println (cando); my. println ("not suitable today"); my. println (canotdo);} public static void main (string [] ARGs) throws parseexception {response = new response (); luozhuangshierjian myluozhuangshierjian = new luozhuangshierjian (); response. test (myluozhuangjiandanxuanri. getbazi ("2013-8-15 "));}}

Result:

Run: Lunar Calendar date [2013]: Lunar Date: in November, the 12 th construction plan is suitable for capturing planting, capturing, creating a well, opening a market, and opening a warehouse today (total time: 0 seconds)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.