List of utility methods to do Year Get
String | getDateOneYearFromNow() get Date One Year From Now String day = "", month = "", year = ""; Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, 1); int mm = (cal.get(Calendar.MONTH) + 1); int dd = cal.get(Calendar.DATE); year = "" + cal.get(Calendar.YEAR); if (mm < 10) month = "0"; ... |
long | getDaysFromYearZero(Calendar date) get Days From Year Zero return ((date.get(Calendar.YEAR) * 365) - 365) + date.get(Calendar.DAY_OF_YEAR);
|
String | getFewYearsTime(String date, int year) get Few Years Time int years = Integer.parseInt(date.split("-")[0]); int month = Integer.parseInt(date.split("-")[1]); int data = Integer.parseInt(date.split("-")[2]); Calendar calendar = new GregorianCalendar(years, month - 1, data); calendar.add(Calendar.YEAR, year); Date d = calendar.getTime(); return new SimpleDateFormat("yyyy-MM-dd").format(d); |
Date | getHalfYearEndDate(Date date) get Half Year End Date try { String strDate = ""; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String format2 = format.format(date); String[] split = format2.split("-"); String year = split[0]; String month = split[1]; int parseInt = Integer.parseInt(month); ... |
Date | getLastDayOfYear(Date date) Function: get LastDay Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int year = calendar.get(Calendar.YEAR); Calendar lastDay = new GregorianCalendar(year, Calendar.DECEMBER, 31); return lastDay.getTime(); |
int | getNextYear() get Next Year return new GregorianCalendar().get(Calendar.YEAR) + 1; |
Date | getNextYearFirst() get Next Year First Calendar currCal = Calendar.getInstance(); int currentYear = currCal.get(Calendar.YEAR); return getYearFirst(currentYear + 1); |
String[] | getNextYearMonthStr() get Next Year Month Str String ret[] = new String[12]; Calendar c = Calendar.getInstance(); int nextYear = c.get(Calendar.YEAR) + 1; for (int i = 0; i < monthStrArray.length; i++) { ret[i] = nextYear + monthStrArray[i]; return ret; |
List | getOfflimitDates(int year) get Offlimit Dates List<Date> offlimitDates = new ArrayList<>();
Calendar baseCalendar = GregorianCalendar.getInstance();
baseCalendar.clear();
baseCalendar.set(year, Calendar.JANUARY, 1);
offlimitDates.add(offsetForWeekend(baseCalendar));
baseCalendar.set(year, Calendar.JULY, 4);
offlimitDates.add(offsetForWeekend(baseCalendar));
baseCalendar.set(year, Calendar.DECEMBER, 25);
...
|
GregorianCalendar | getRandomDate(int firstYar, int lastYear) get Random Date int month, day, year, maxday; year = getRandomInt(firstYar, lastYear); month = getRandomInt(0, 11); maxday = 31; if (month == 3 | month == 5 | month == 8 | month == 10) { maxday = 30; } else if (month == 1) { maxday = 28; ... |