Formatter for a date.

@param year [0..9999].
@param month [1..12].
@param day day of month [1..31].
@return the ISO formatted date.
549913
public static String format(Integer year, Integer month, Integer day)
	{
		Object[] _args =
		{
				year, month, day
		};
		return SHORT__DATE.format(_args);
	}
11157
public static Integer getDayOfYear(Date date) {

        if (date == null)
            return null;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        return calendar.get(Calendar.DAY_OF_YEAR);
    }
1025292
private static int getDayOfMonth(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return cal.get(Calendar.DAY_OF_MONTH);
	}
574610
private Calendar getCalendar(String iso8601Date) throws
      InvalidDateException
  {
    // YYYY-MM-DDThh:mm:ss.sTZD
    StringTokenizer st = new StringTokenizer(iso8601Date, "-T:.+Z", true);
    if (!st.hasMoreTokens())
    {
      throw new InvalidDateException("Empty Date");
    }
    Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    calendar.clear();
    try
    {
      // Year
      if (st.hasMoreTokens())
      {
        int year = Integer.parseInt(st.nextToken());
        calendar.set(Calendar.YEAR, year);
      }
      else
      {
        return calendar;
      }
      // Month
      if (checkValueAndNext(st, "-"))
      {
        int month = Integer.parseInt(st.nextToken()) - 1;
        calendar.set(Calendar.MONTH, month);
      }
      else
      {
        return calendar;
      }
      // Day
      if (checkValueAndNext(st, "-"))
      {
        int day = Integer.parseInt(st.nextToken());
        calendar.set(Calendar.DAY_OF_MONTH, day);
      }
      else
      {
        return calendar;
      }
      // Hour
      if (checkValueAndNext(st, "T"))
      {
        int hour = Integer.parseInt(st.nextToken());
        calendar.set(Calendar.HOUR_OF_DAY, hour);
      }
      else
      {
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar;
      }
      // Minutes
      if (checkValueAndNext(st, ":"))
      {
        int minutes = Integer.parseInt(st.nextToken());
        calendar.set(Calendar.MINUTE, minutes);
      }
      else
      {
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar;
      }
      if (!st.hasMoreTokens())
      {
        return calendar;
      }
      // Not mandatory now
      // Seconds
      String tok = st.nextToken();
      if (tok.equals(":"))
      { // seconds
        if (st.hasMoreTokens())
        {
          int secondes = Integer.parseInt(st.nextToken());
          calendar.set(Calendar.SECOND, secondes);
          if (!st.hasMoreTokens())
          {
            return calendar;
          }
          // decimal fraction of a second
          tok = st.nextToken();
          if (tok.equals("."))
          {
            String nt = st.nextToken();
            while (nt.length() < 3)
            {
              nt += "0";
            }
            if (nt.length() > 3)
            {
              // check the other part from the decimal fraction to be formed only from digits
              for (int i = 3; i < nt.length(); i++)
              {
                if (!Character.isDigit(nt.charAt(i)))
                {
                  throw new InvalidDateException("Invalid digit in the decimal fraction of a second: " + nt.charAt(i));
                }
              }
            }
            nt = nt.substring(0, 3); //Cut trailing chars..
            int millisec = Integer.parseInt(nt);
            calendar.set(Calendar.MILLISECOND, millisec);
            if (!st.hasMoreTokens())
            {
              return calendar;
            }
            tok = st.nextToken();
          }
          else
          {
            calendar.set(Calendar.MILLISECOND, 0);
          }
        }
        else
        {
          throw new InvalidDateException("No secondes specified");
        }
      }
      else
      {
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
      }
      // Time zone
      if (!tok.equals("Z"))
      { // UTC
        if (!(tok.equals("+") || tok.equals("-")))
        {
          throw new InvalidDateException("only Z, + or - allowed");
        }
        boolean plus = tok.equals("+");
        if (!st.hasMoreTokens())
        {
          throw new InvalidDateException("Missing hour field");
        }
        int tzhour = Integer.parseInt(st.nextToken());
        int tzmin;
        if (checkValueAndNext(st, ":"))
        {
          tzmin = Integer.parseInt(st.nextToken());
        }
        else
        {
          throw new InvalidDateException("Missing minute field");
        }
        if (plus)
        {
          calendar.add(Calendar.HOUR, -tzhour);
          calendar.add(Calendar.MINUTE, -tzmin);
        }
        else
        {
          calendar.add(Calendar.HOUR, tzhour);
          calendar.add(Calendar.MINUTE, tzmin);
        }
      }
      else
      {
        if (st.hasMoreTokens())
        {
          throw new InvalidDateException("Unexpected field at the end of the date field: " + st.nextToken());
        }
      }
    }
    catch (NumberFormatException ex)
    {
      throw new InvalidDateException("[" + ex.getMessage() + "] is not an integer");
    }
    return calendar;
  }
253042
private static Date getDate(int day, int month, int year) {
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.YEAR, year);
		cal.set(Calendar.MONTH, month);
		cal.set(Calendar.DATE, day);
		return cal.getTime();
	}
156635
void formatDayOfYear(StringBuilder b, ZonedDateTime d, int width) {
    int day = d.getDayOfYear();
    int digits = day < 10 ? 1 : day < 100 ? 2 : 3;
    switch (digits) {
      case 1:
        if (width > 1) {
          b.append('0');
        }
        // fall through

      case 2:
        if (width > 2) {
          b.append('0');
        }
        // fall through

      case 3:
        b.append(day);
        break;
    }
  }
631335
protected static function getDayOfYear($day, $month) {
        
        $dayOfYear = $day;
        if ($month > 6) {
            $dayOfYear += (186 + (($month - 6 - 1) * 30));
        } else {
            $dayOfYear += (($month - 1) * 31);
        }
        
        return $dayOfYear;
    }
604700
public static LocalDate date(EvaluationContext ctx, Object year, Object month, Object day) {
        return LocalDate.of(Conversions.toInteger(year, ctx), Conversions.toInteger(month, ctx), Conversions.toInteger(day, ctx));
    }
1047889
public function convertGregorianToJd($year, $month, $day)
    {
        // Special case mapping 0/0/0 -> 0
        if ($year == 0 || $month == 0 || $day == 0) {
            return 0;
        }

        $m1412 = ($month <= 2) ? - 1 : 0;
        return floor((1461 * ($year + 4800 + $m1412)) / 4) + floor((367 * ($month - 2 - 12 * $m1412)) / 12) -
             floor((3 * floor(($year + 4900 + $m1412) / 100)) / 4) + $day - 32075;
    }
349377
private long monthToDayOfYear(long month, boolean isLeapYear)
  {
    long day = 0;

    for (int i = 0; i < month && i < 12; i++) {
      day += DAYS_IN_MONTH[i];
      if (i == 1 && isLeapYear)
        day++;
    }

    return day;
  }
663453
public static String getDate(int days, int months, int years, String format) {
        return getDate(days, months, years, format, Locale.ENGLISH);
    }
991198
public static int getDayOfYear(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c.get(Calendar.DAY_OF_YEAR);
    }
262279
private String formatDate(final WPartialDateField dateField) {
		Integer day = dateField.getDay();
		Integer month = dateField.getMonth();
		Integer year = dateField.getYear();

		if (day != null || month != null || year != null) {
			StringBuffer buf = new StringBuffer(10);

			append(buf, year, 4);
			buf.append('-');
			append(buf, month, 2);
			buf.append('-');
			append(buf, day, 2);

			return buf.toString();
		}

		return null;
	}
323988
public static int getYearDay(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    }
1169344
public static java.util.Date getDayAsDate(int day) {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, day);
        return cal.getTime();
    }
1328745
private function isDateValid(int $year, int $month, int $day) : bool
    {
        if ($day === 0) {
            return false;
        }

        switch ($month) {
            case 2:
                $days = $this->isLeapYear($year) ? 29 : 28;
                break;

            case 4:
            case 6:
            case 9:
            case 11:
                $days = 30;
                break;

            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                $days = 31;
                break;

            default:
                return false;
        }

        return $day <= $days;
    }
1218319
public function ymdToJd($year, $month, $day)
    {
        if ($month < 1 || $month > $this->monthsInYear()) {
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
        }

        $epbase = $year - (($year >= 0) ? 474 : 473);
        $epyear = 474 + $this->mod($epbase, 2820);

        return
            $day +
            (($month <= 7) ? (($month - 1) * 31) : ((($month - 1) * 30) + 6)) +
            (int) ((($epyear * 682) - 110) / 2816) +
            ($epyear - 1) * 365 +
            (int) (floor($epbase / 2820)) * 1029983 +
            $this->jdStart() - 1;
    }