Android Hour Format getDateByAddHour(String datetime, int minute)

Here you can find the source of getDateByAddHour(String datetime, int minute)

Description

get Date By Add Hour

License

Apache License

Declaration

public static String getDateByAddHour(String datetime, int minute) 

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;
import java.util.GregorianCalendar;

public class Main {

    public static String getDateByAddHour(String datetime, int minute) {
        String returnTime = null;
        Calendar cal = new GregorianCalendar();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date;//  w  ww . j  av  a  2  s. com
        try {
            date = ft.parse(datetime);
            cal.setTime(date);
            cal.add(GregorianCalendar.MINUTE, minute);
            returnTime = getFormatDateTime(cal.getTime(),
                    "yyyy-MM-dd HH:mm:ss");
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return returnTime;

    }

    public static String getFormatDateTime(Date date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
}

Related

  1. formatHour(String string)
  2. formatHour(int val)
  3. getReminderReadableTime(int hour, int minute)
  4. getCurrentHour()
  5. getDateByAddFltHour(float flt)
  6. homiToString(int hour, int minute)
  7. formatElapsedTime(StringBuilder recycle, String format, long hours, long minutes, long seconds)
  8. time2String(int hour, int minute)