整理一篇Java計算年齡的工具類,方便實用 public static int getAgeByBirth(String birthday) throws ParseException { // 格式化传入的时间 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date parse = format.parse(birthday); int age = 0; try { Calendar now = Calen…
星座: public static String getStar(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int month = cal.get(Calendar.MONTH) + 1; int day = cal.get(Calendar.DAY_OF_MONTH); String star = ""; if (month == 1 && day >= 20 |…