List of utility methods to do Year Get
String | getYearName(String dateString) get Year Name String returnString; java.util.Date date = getDate(dateString); SimpleDateFormat sdf = new SimpleDateFormat("yy"); returnString = sdf.format(date); return returnString; |
int | getYearsOfAge(Date birthDate, Date nowDate) get Years Of Age Calendar birth = new GregorianCalendar(); birth.setTime(birthDate); Calendar now = new GregorianCalendar(); now.setTime(nowDate); int year = now.get(Calendar.YEAR) - birth.get(Calendar.YEAR); if ((birth.get(Calendar.MONTH) > now.get(Calendar.MONTH)) || (birth.get(Calendar.MONTH) == now.get(Calendar.MONTH) && birth.get(Calendar.DAY_OF_MONTH) > now.get(Calendar.DAY_OF_MONTH))) { ... |
String | getYearString() get Year String return getFormat(yearFormat).format(new Date()); |
String[] | getYearWeek(int year, int week) get Year Week String result = ""; Calendar cal = new GregorianCalendar(Locale.CHINESE); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); Date day = new Date(year - 1900, 0, 1); for (int i = 0; i < 366; i++) { cal.setTime(day); if (cal.get(Calendar.DAY_OF_WEEK) == week) { if (day.getYear() == year - 1900) ... |