Java Date Add dateAddHours(Date time, int hours, SimpleDateFormat dateFormat)

Here you can find the source of dateAddHours(Date time, int hours, SimpleDateFormat dateFormat)

Description

date Add Hours

License

Open Source License

Declaration

public static String dateAddHours(Date time, int hours, SimpleDateFormat dateFormat) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String dateAddHours(Date time, int hours, SimpleDateFormat dateFormat) {
        long timeLong = time.getTime() / 1000 + 60l * 60 * hours;
        time.setTime(timeLong * 1000);/*  ww w.j av a  2  s. c o  m*/
        String timeStr = dateFormat.format(time);
        return timeStr;
    }
}

Related

  1. dateAddDay(Date date, int day)
  2. DateAddDays(Date _date, int days)
  3. dateAddDays(Date date, int days)
  4. dateAddDays(Date date, int days)
  5. dateAddDays(Date time, int days, String dateFormat)
  6. dateAddMinutes(Date date, int minutes)
  7. dateAddMM(Date date, int i)
  8. dateAddMonths(Date date, int addMonths)
  9. dateAddSpaceMilliSecond(Date date, int milliSecond)