List of utility methods to do Year Day
String | getCurrYearFirstDay(int year) get Curr Year First Day SimpleDateFormat format = new SimpleDateFormat(default_format); Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.YEAR, year); Date currYearFirst = calendar.getTime(); return format.format(currYearFirst); |
String | getFirstDay4CurrentYear() get First Day Current Year SimpleDateFormat df = new SimpleDateFormat("yyyy"); String todayAsString = df.format(new Date()); todayAsString = todayAsString + "-01-01"; return todayAsString; |
String | getFirstDayOfThisYear() get First Day Of This Year Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, 1); calendar.set(Calendar.DAY_OF_YEAR, 1); Date date = new Date(calendar.getTimeInMillis()); return shortDateFormat.format(date); |
Date | getLastDayOfTheYear(int year) get Last Day Of The Year Calendar lastDayOfThisYear = Calendar.getInstance();
lastDayOfThisYear.clear();
lastDayOfThisYear.set(Calendar.YEAR, year);
lastDayOfThisYear.set(Calendar.DAY_OF_YEAR, 1);
lastDayOfThisYear.add(Calendar.YEAR, 1);
lastDayOfThisYear.add(Calendar.MILLISECOND, -1);
return lastDayOfThisYear.getTime();
|
Date | getLastDayOfYear(int year) get Last Day Of Year return getEndDate(Calendar.DECEMBER, year);
|
Date | getLastDayOfYear(int year) get Last Day Of Year return getLastDayOfQuarter(year, 4);
|
int | getTodayYear() get Today Year int yyyy = Integer.parseInt(dateFormat(new Date(), "yyyy")); return yyyy; |
int | getWeekNumOfYearDay(String strDate) get Week Num Of Year Day Calendar calendar = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date curDate = format.parse(strDate); int iWeekNum; calendar.setTime(curDate); if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { iWeekNum = calendar.get(Calendar.WEEK_OF_YEAR) - 1; } else { ... |
Date | getYearFirstDay(String date) get Year First Day SimpleDateFormat format = new SimpleDateFormat("yyyy"); Date d = null; try { d = format.parse(date); } catch (Exception e) { e.printStackTrace(); Calendar cal = Calendar.getInstance(); ... |
Date | getYearLastDay(String dateString) return the last day of the date's year of specified string value in format: yyyy SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy"); Date date = null; try { date = simpleDateFormat.parse(dateString); } catch (Exception e) { e.printStackTrace(); Calendar calendar = Calendar.getInstance(); ... |