BrithdayStar.java 1.08 KB
package com.hjx.personalcenter.util;

/**
 * Created by h on 2017/8/22.
 */

public class BrithdayStar {
    String[][] constellations = {{"摩羯座", "水瓶座"}, {"水瓶座", "双鱼座"}, {"双鱼座", "白羊座"}, {"白羊座", "金牛座"}, {"金牛座", "双子座"}, {"双子座", "巨蟹座"}, {"巨蟹座", "狮子座"},
            {"狮子座", "处女座"}, {"处女座", "天秤座"}, {"天秤座", "天蝎座"}, {"天蝎座", "射手座"}, {"射手座", "摩羯座"}};
    //星座分割时间
    int[] date = {20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22};
    //星座生成 传进是日期格式为: yyyy-mm-dd
    public String  getConstellations(String birthday) {
        String become_constellation = null;
        String[] data = birthday.split("-");
        int day = date[Integer.parseInt(data[1]) - 1];
        String[] cl1 = constellations[Integer.parseInt(data[1]) - 1];
        if (Integer.parseInt(data[2]) >= day) {
            become_constellation =cl1[1];
        } else {
            become_constellation=cl1[0];
        }
        return become_constellation;
    }
}