Java Hour Calculate getBothTime(String startTime, int hours)

Here you can find the source of getBothTime(String startTime, int hours)

Description

get Both Time

License

LGPL

Declaration

public static String getBothTime(String startTime, int hours) 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String getBothTime(String startTime, int hours) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {/*  w  ww.j  a v a 2s  . c o  m*/
            Date date = sdf.parse(startTime);
            Date retDate = new Date(date.getTime() + hours * 3600000l);
            return sdf.format(retDate);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. addHour(String now)
  2. addHours(int date, int hours)
  3. addNHours(Date date, int hours)
  4. diffHour(String day1, String day2)
  5. getCurrHourDate()
  6. getDelayEndTime(int hour, String timezone)
  7. getDelayTime(int hour, String date)
  8. getDiffDateTime(int diff, int hours)