List of utility methods to do Date to Year
int | getYear(java.util.Date date) get Year java.util.Calendar c = java.util.Calendar.getInstance();
c.setTime(date);
return c.get(java.util.Calendar.YEAR);
|
Integer | getYear(java.util.Date today) getYear: returns the year of the date if (today != null) { java.util.Calendar c = java.util.Calendar.getInstance(Locale.GERMANY); c.setTime(today); return c.get(Calendar.YEAR); } else { return null; |
String | getYear(String sdate) get Year String[] date = sdate.split("-"); return date[0]; |
int | getYear(String strDate) get Year Calendar cal = parseDateTime(strDate);
return cal.get(Calendar.YEAR) + 1900;
|
int | getYearAsInt(Date aDate) get Year As Int Calendar c = Calendar.getInstance();
c.setTime(aDate);
return c.get(Calendar.YEAR);
|
Date | getYearBegin(final Date date) get Year Begin if (date == null) { return null; Calendar cal = GregorianCalendar.getInstance(); cal.setTime(date); cal.set(Calendar.MONTH, 0); cal.set(Calendar.DATE, 1); return cal.getTime(); ... |
int | getYearBetweenTwoDate(Date fdate, Date tdate) Return offset years between specified begin date and end date Calendar f = Calendar.getInstance();
f.setTime(fdate);
Calendar t = Calendar.getInstance();
t.setTime(tdate);
return t.get(Calendar.YEAR) - f.get(Calendar.YEAR);
|
Integer | getYearFromDate(Date date) get Year From Date Integer result = null; if (date != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); result = calendar.get(Calendar.YEAR); return result; |
String | getYearFromDate(Date date) get Year From Date if (date == null) { return null; Calendar cal = Calendar.getInstance(); cal.setTime(date); return String.valueOf(cal.get(Calendar.YEAR)); |
String | getYearMonth(Date date) get Year Month Calendar c = new GregorianCalendar(); c.setTime(date); return c.get(Calendar.YEAR) + "-" + (c.get(Calendar.MONTH) + 1); |