Add hours to a date

@param d date
@param hours hours
@return new date
486518
public static Date addHours(Date d, int hours) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        cal.add(Calendar.HOUR_OF_DAY, hours);
        return cal.getTime();
    }
1092761
function (d, range) {
		"use strict";

		var start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
		var stop = null;
		if (range instanceof Date) {
			stop = new Date(range.getFullYear(), range.getMonth(), range.getDate(), range.getHours());
		} else {
			stop = new Date(start);
			stop.setHours(stop.getHours() + range);
		}

		var domains = d3.time.hours(Math.min(start, stop), Math.max(start, stop));

		// Passing from DST to standard time
		// If there are 25 hours, let's compress the duplicate hours
		var i = 0;
		var total = domains.length;
		for(i = 0; i < total; i++) {
			if (i > 0 && (domains[i].getHours() === domains[i-1].getHours())) {
				this.DSTDomain.push(domains[i].getTime());
				domains.splice(i, 1);
				break;
			}
		}

		// d3.time.hours is returning more hours than needed when changing
		// from DST to standard time, because there is really 2 hours between
		// 1am and 2am!
		if (typeof range === "number" && domains.length > Math.abs(range)) {
			domains.splice(domains.length-1, 1);
		}

		return domains;
	}
241927
private Date addDays(final Date date, final int days) {
        final Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.DATE, days); //minus number would decrement the days
        return cal.getTime();
    }
154843
public static <D extends Comparable> DateTimeExpression<D> addDays(DateTimeExpression<D> date, int days) {
        return Expressions.dateTimeOperation(date.getType(), Ops.DateTimeOps.ADD_DAYS, date, ConstantImpl.create(days));
    }
953830
public function addHours($hours)
    {
        $hours = (int) $hours;
        $interval = new DateInterval('PT' . abs($hours) . 'H');

        if ($hours < 0) {
            $interval->invert = 1;
        }

        return $this->add($interval);
    }
1074706
static Date toDate(double d) {
        GregorianCalendar ret = new GregorianCalendar(1899,11,30);
        int days = (int)d;
        d -= days;
        ret.add(Calendar.DATE,days);
        d *= 24;
        int hours = (int)d;
        ret.add(Calendar.HOUR,hours);
        d -= hours;
        d *= 60;
//        d += 0.5; // round
        int min = (int)d;
        ret.add(Calendar.MINUTE,min);

        d -= min;
        d *= 60;
        int secs = (int) d;
        ret.add(Calendar.SECOND, secs);

        return ret.getTime();
    }
345217
private long parseTime(String day, String hours)
    {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        Date utcDate = new Date();
        try {
            utcDate = format.parse(day.concat(" " + hours));
        } catch (Exception e) {

        }
        return utcDate.getTime();
    }
183698
public static Date addDays(Date date, int numberOfDays) {
    return Date.from(date.toInstant().plus(numberOfDays, ChronoUnit.DAYS));
  }
1264407
void formatHours(StringBuilder b, ZonedDateTime d, int width, boolean twelveHour) {
    int hours = d.getHour();
    if (twelveHour && hours > 12) {
      hours = hours - 12;
    }
    if (twelveHour && hours == 0) {
      hours = 12;
    }
    zeroPad2(b, hours, width);
  }
1113266
private void addHours(MpxjTreeNode parentNode, ProjectCalendarDateRanges hours)
   {
      for (DateRange range : hours)
      {
         final DateRange r = range;
         MpxjTreeNode rangeNode = new MpxjTreeNode(range)
         {
            @Override public String toString()
            {
               return m_timeFormat.format(r.getStart()) + " - " + m_timeFormat.format(r.getEnd());
            }
         };
         parentNode.add(rangeNode);
      }
   }
178951
function(date, range) {
		"use strict";

		if (typeof date === "number") {
			date = new Date(date);
		}

		if (arguments.length < 2) {
			range = this.options.range;
		}

		switch(this.options.domain) {
		case "hour" :
			var domains = this.getHourDomain(date, range);

			// Case where an hour is missing, when passing from standard time to DST
			// Missing hour is perfectly acceptabl in subDomain, but not in domains
			if (typeof range === "number" && domains.length < range) {
				if (range > 0) {
					domains.push(this.getHourDomain(domains[domains.length-1], 2)[1]);
				} else {
					domains.shift(this.getHourDomain(domains[0], -2)[0]);
				}
			}
			return domains;
		case "day"  :
			return this.getDayDomain(date, range);
		case "week" :
			return this.getWeekDomain(date, range);
		case "month":
			return this.getMonthDomain(date, range);
		case "year" :
			return this.getYearDomain(date, range);
		}
	}
986997
private void addHours(ProjectCalendarDateRanges ranges, Record hoursRecord)
   {
      if (hoursRecord.getValue() != null)
      {
         String[] wh = hoursRecord.getValue().split("\\|");
         try
         {
            String startText;
            String endText;

            if (wh[0].equals("s"))
            {
               startText = wh[1];
               endText = wh[3];
            }
            else
            {
               startText = wh[3];
               endText = wh[1];
            }

            // for end time treat midnight as midnight next day
            if (endText.equals("00:00"))
            {
               endText = "24:00";
            }
            Date start = m_calendarTimeFormat.parse(startText);
            Date end = m_calendarTimeFormat.parse(endText);

            ranges.addRange(new DateRange(start, end));
         }
         catch (ParseException e)
         {
            // silently ignore date parse exceptions
         }
      }
   }
1178756
public Map<Integer, Hour> getHours(DayOfWeek day) {
    if (hours.get(day) == null) {
      return null;
    }

    return Collections.unmodifiableMap(hours.get(day));
  }
214906
public static Date addMinutes(final Date date, final int addMinutes)
	{
		final Calendar dateOnCalendar = Calendar.getInstance();
		dateOnCalendar.setTime(date);
		dateOnCalendar.add(Calendar.MINUTE, addMinutes);
		return dateOnCalendar.getTime();
	}
974561
function (date, ampm) {
            var d = date,
                hours = date;

            if (date instanceof Date) {
                d = dp.getParsedDate(date);
                hours = d.hours;
            }

            var _ampm = ampm || this.d.ampm,
                dayPeriod = 'am';

            if (_ampm) {
                switch(true) {
                    case hours == 0:
                        hours = 12;
                        break;
                    case hours == 12:
                        dayPeriod = 'pm';
                        break;
                    case hours > 11:
                        hours = hours - 12;
                        dayPeriod = 'pm';
                        break;
                    default:
                        break;
                }
            }

            return {
                hours: hours,
                dayPeriod: dayPeriod
            }
        }
728348
public static Date addMilliseconds(final Date date, final int addMilliseconds)
	{
		final Calendar dateOnCalendar = Calendar.getInstance();
		dateOnCalendar.setTime(date);
		dateOnCalendar.add(Calendar.MILLISECOND, addMilliseconds);
		return dateOnCalendar.getTime();
	}
620759
public CreateIssueParams actualHours(BigDecimal actualHours) {
        if (actualHours == null) {
            parameters.add(new NameValuePair("actualHours", ""));
        } else {
            parameters.add(new NameValuePair("actualHours", actualHours.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()));
        }
        return this;
    }