Android Utililty Methods Year Get

List of utility methods to do Year Get

Description

The list of methods to do Year Get are organized into topic(s).

Method

DategetIndexYear(Date origin, int index)
get Index Year
Date dt = origin;
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(dt);
rightNow.add(Calendar.YEAR, index);
Date dt1 = rightNow.getTime();
return dt1;
intgetCurrentYear()
get Current Year
Calendar calendar = new GregorianCalendar();
calendar.setTime(new Date());
return calendar.get(Calendar.YEAR);
StringgetCurrentYear()
get Current Year
DateFormat tempDate = new SimpleDateFormat("yyyy");
return tempDate.format(new java.util.Date());
StringgetCurrentYear()
get Current Year
return getFormatCurrentTime("yyyy");
StringgetBeforeYear()
get Before Year
String currentYear = getFormatCurrentTime("yyyy");
int beforeYear = Integer.parseInt(currentYear) - 1;
return "" + beforeYear;
booleanisInCurrentYear(long lTime)
is In Current Year
Calendar cal = Calendar.getInstance();
Calendar calUnknown = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
calUnknown.setTimeInMillis(lTime);
int nDayOfYear = cal.get(Calendar.DAY_OF_YEAR);
cal.add(Calendar.DAY_OF_YEAR, 0 - nDayOfYear);
if (calUnknown.before(cal)) {
    return false;
...
intgetCurrentYear()
get Current Year
CALENDAR.setTime(new Date());
return CALENDAR.get(Calendar.YEAR);
intgetYear()
get Year
return Calendar.getInstance().get(Calendar.YEAR);
intgetYearByMillis(long millis)
get Year By Millis
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(millis);
return calendar.get(Calendar.YEAR);