Java Utililty Methods Day Of Year

List of utility methods to do Day Of Year

Description

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

Method

DategetLastYearOfToday()
get Last Year Of Today
return rollYear(new Date(), -1);
intgetMaxDayByYearMonth(String ym)
get Max Day By Year Month
int day = 0;
try {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
    Calendar calendar = new GregorianCalendar();
    Date date = sdf.parse(ym);
    calendar.setTime(date);
    day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
} catch (ParseException e) {
...
StringgetMaxDayOfYearMonth(String date)
get Max Day Of Year Month
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
try {
    Date d = sdf.parse(date);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(d);
    int lastDayNum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    date = date + "-" + lastDayNum;
} catch (ParseException e) {
...
intgetMaxWeekNumOfYear(int year)
get Max Week Num Of Year
Calendar c = new GregorianCalendar();
c.set(year, Calendar.DECEMBER, 31, 23, 59, 59);
return getWeekOfYear(c.getTime());