Java Hour Calculate getDelayTime(int hour, String date)

Here you can find the source of getDelayTime(int hour, String date)

Description

get Delay Time

License

Apache License

Declaration

public static String getDelayTime(int hour, String date) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String getDelayTime(int hour, String date) throws ParseException {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(string2Date(date).getTime());
        calendar.add(10, hour);/*  w  w w.  j av a 2s. c  o  m*/
        SimpleDateFormat dateFormatGmt = new SimpleDateFormat(DATE_FORMAT);
        return dateFormatGmt.format(calendar.getTime());
    }

    public static Date string2Date(String dateString) throws ParseException {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateString);
    }
}

Related

  1. addNHours(Date date, int hours)
  2. diffHour(String day1, String day2)
  3. getBothTime(String startTime, int hours)
  4. getCurrHourDate()
  5. getDelayEndTime(int hour, String timezone)
  6. getDiffDateTime(int diff, int hours)
  7. getDiffHour(String startTime, String endTime)
  8. getDoubleValue(String hours)
  9. getExpiresDate(int hours)