Calculates 12 constellations for a given Gregorian date (Java code implementation)

Source: Internet
Author: User

Given the Gregorian date, the 12 constellations that are returned for that date are calculated.

public static String getxingzuoname (int month, Int. day);

Note: The parameter month and day are both Gregorian and Japanese.

The name of the returned Chinese constellation: Virgo.


Import Java.util.map;import java.util.hashmap;import Java.util.arraylist;import java.util.list;// Importandroid.util.log;public class Xingzuo {private static list<map<string, object>> List = null;private Static float[][] Floatxingzuo = Null;public Xingzuo () {//List=loadxingzuo12 ();//Floatxingzuo=loadxingzuofloatvalue () ;} public static String getxingzuoname (int month, Int. day) {if (Floatxingzuo = = null) Floatxingzuo = Loadxingzuofloatvalue (); S  Tring ds = String.Format ("%02d", day), float target = float.valueof (month + "." + DS); Boolean bool1 = Float.compare (target, 12.22f) >= 0? True:false;boolean bool2 = Float.compare (target, 1.20f) <= 0? True:false;if (Bool1 | | bool2) {return "Capricorn";}  int I;boolean B1, b2;for (i = 0; i <; i++) {B1 = Float.compare (target, floatxingzuo[0][i]) >= 0? true:false;b2 = Float.compare (target, floatxingzuo[1][i]) <= 0? True:false;if (B1 && B2) break;} Map map = (map) (List.get (i)), return Map.get ("xingzuo_name") + "";} PRivate static float[][] Loadxingzuofloatvalue () {if (list = = null) List = LoadXingZuo12 ();  Map map = null;//String xzname=null;int mind, Maxd, MINM, maxm;float[][] Fxingzuo = new Float[2][12];float start, end;for (int i = 0; i <; i++) {map = (map) (List.get (i)), mind = Integer.parseint (Map.get ("min_day") + ""), Maxd = Integer.parseint (Map.get ("max_day") + MINM = Integer.parseint (Map.get ("min_month") + ""), Maxm = Integer.parseint (Map.get ("max_month") + ""); start = Float.valueof (MINM + "." + mind); end = float.valueof (Maxm + "." + Maxd); Fxingzuo[0][i] = start;fxingzuo[1][i] = end;} return Fxingzuo;} private static List loadXingZuo12 () {String xingzuo_name = "Xingzuo_name"; String min_day = "Min_day"; String min_month = "Min_month"; String max_day = "Max_day"; String max_month = "Max_month"; list<map<string, object>> list = new arraylist<map<string, object>> (); map<string, object> map = Null;map = new hashmap<string, object> (); Map.put (Xingzuo_name, "Aries"); Map.put (Min_day); Map.put (Max_day); Map.put (Min_month, 3); Map.put (Max_month, 4); List.add (map); map = new Hashmap<string, object> (); Map.put (Xingzuo_name, "Taurus"); Map.put (Min_day); Map.put (Max_day); Map.put (MIN _month, 4); Map.put (Max_month, 5); List.add (map); map = new hashmap<string, object> (); Map.put (Xingzuo_name, "Gemini") ; Map.put (Min_day); Map.put (Max_day); Map.put (Min_month, 5); Map.put (Max_month, 6); List.add (map); map = new Hashmap<string, Object> (), Map.put (Xingzuo_name, "cancer"), Map.put (Min_day); Map.put (Max_day); Map.put (MIN _month, 6); Map.put (Max_month, 7); List.add (map); map = new hashmap<string, object> (); Map.put (Xingzuo_name, "Leo") ; Map.put (Min_day); Map.put (Max_day, 23°c); Map.put (Min_month, 7); Map.put (Max_month, 8); List.add (map); map = new Hashmap<string, Object> (), Map.put (Xingzuo_name, "Virgo"), Map.put (Min_day), Map.put (Max_day, 23°c); Map.put (MIN _month, 8); Map.put (Max_month, 9); List.add (map); map = new hashmap<string, object> (); MAP.put (Xingzuo_name, "Libra"); Map.put (Min_day); Map.put (Max_day); Map.put (Min_month, 9); Map.put (Max_month, 10); List.add (map), map = new hashmap<string, object> (), Map.put (Xingzuo_name, "Scorpio"), Map.put (Min_day); Map.put ( Max_day, Map.put (Min_month), Map.put (Max_month, one), List.add (map), map = new hashmap<string, object> (); Map.put (Xingzuo_name, "Sagittarius"); Map.put (min_day,; map.put); Max_day (Map.put, one); Min_month (Map.put, 12 ); List.add (map); map = new hashmap<string, object> (); Map.put (Xingzuo_name, "Capricorn"); Map.put (Min_day); Map.put ( Max_day, Map.put (Min_month); Map.put (Max_month, 1); List.add (map); map = new hashmap<string, object> (); Map.put (Xingzuo_name, "Aquarius"); Map.put (Min_day); Map.put (Max_day); Map.put (Min_month, 1); Map.put (Max_month, 2); List.add (map), map = new hashmap<string, object> (), Map.put (Xingzuo_name, "Pisces"), Map.put (Min_day); Map.put ( Max_day, Map.put (Min_month, 2); Map.put (Max_month, 3); List.add (map); return list;}} 



Calculates 12 constellations for a given Gregorian date (Java code implementation)

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.