/**
*
* @author: moshangpiaoxue
* @todo:通过日期判断星座工具类,这个方法只能返回星座的字符串
* @file_name:TimeTools.java
* @date:2015-11-27
* @time下午5:27:22
*/
public class TimeTools {
public static String getAstro(int month, int day) {
String[] astro = new String[] { "摩羯座", "水瓶座", "双鱼座", "白羊座", "金牛座",
"双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座" };
int[] arr = new int[] { 20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22 };// 两个星座分割日
int index = month;
// 所查询日期在分割日之前,索引-1,否则不变
if (day < arr[month - 1]) {
index = index - 1;
}
// 返回索引指向的星座string
return astro[index];
}
}