code: private static int getDayOfMonth(int dayOfYear, int month, int year) {
  
          Integer[] newMonths = getAdjustedMonthDays(year);
  
          if (dayOfYear >= 0) {
              if (month > 0) {
                  return dayOfYear - newMonths[month].intValue();
              } else {
                  return dayOfYear;
              }
          } else {
              dayOfYear = (isLeapYear(year) ? (dayOfYear + 355)
                      : (dayOfYear + 354));
              if (month > 0) {
                  return dayOfYear - newMonths[month].intValue();
              } else {
                  return dayOfYear;
              }
          }
      }
docs: Returns day-of-month.
  
  @param dayOfYear  day of  year
  @param month  month
  @param year  year
  @return day-of-month