Package com. test;
Import java. util. calendar;
Public class test {
/**
* @ Param ARGs
*/
Public static final string [] zodiacarr = {"monkey", "chicken", "dog", "Swine", "rat", "Ox", "Tiger ", "rabbit", "dragon", "snake", "horse", "goat "};
Public static final string [] constellationarr = {"Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "cancer", "Leo ", "Virgo", "Libra ",
"Scorpio", "Sagittarius", "Capricorn "};
Public static final int [] constellationedgeday = {20, 19, 21, 21, 21, 22, 23, 23, 23, 22, 22 };
/**
* Obtain the Chinese zodiac by date
* @ Return
*/
Public static string date2zodica (calendar time ){
Return zodiacarr [time. Get (calendar. Year) % 12];
}
/**
* Retrieve the Constellation by date
* @ Param time
* @ Return
*/
Public static string date2constellation (calendar time ){
Int month = time. Get (calendar. month );
Int day = time. Get (calendar. day_of_month );
If (day <constellationedgeday [month]) {
Month = month-1;
}
If (month> = 0 ){
Return constellationarr [month];
}
// Default to return magic wand
Return constellationarr [11];
}
Public static void main (string [] ARGs ){
String test = date2constellation (calendar. getinstance ());
System. Out. println ("constellation:" + test );
String test1 = date2zodica (calendar. getinstance ());
System. Out. println ("Zodiac:" + test1 );
}
}