Android Utililty Methods Year Offset Get

List of utility methods to do Year Offset Get

Description

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

Method

doubledeltaTimeCurrentCentury(int year)
Calculates the difference between the Universal Time and the Terrestrial Time (also known as Dynamical Time) given a year within the 21st century.
double t = (double) (year - 2000) / 100;
return (102 + 102 * t + 25.3 * t * t + (year - 2100) * 0.37);
booleanhasYearPassed(int year)
has Year Passed
int normalized = normalizeYear(year);
Calendar now = Clock.getCalendarInstance();
return normalized < now.get(Calendar.YEAR);
DateyearOffset(Date date, int offset)
year Offset
return offsetDate(date, Calendar.YEAR, offset);
StringgetOneYearAgo()
get One Year Ago
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -365);
return dateFormat.format(cal.getTime());
intyearDays(int y)
year Days
int i, sum = 348;
for (i = 0x8000; i > 0x8; i >>= 1) {
    if ((lunarInfo[y - 1900] & i) != 0)
        sum += 1;
return (sum + leapDays(y));
StringgetYearMonthDay1()
get Year Month Day
java.sql.Date date2 = new java.sql.Date(System.currentTimeMillis());
return date2.toString();
StringgetYearMonthDay2()
get Year Month Day
java.util.Date date1 = new java.util.Date();
java.sql.Date date3 = new java.sql.Date(date1.getTime());
return date3.toString();
StringgetYear_Second1()
get Yea Second
Timestamp stamp1 = new Timestamp(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String timeStr = sdf.format(stamp1);
return timeStr;
StringgetYear_Second2()
get Yea Second
java.util.Date date1 = new java.util.Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String timeStr2 = df.format(date1);
return timeStr2;