Java Minute Calculate getTimeAddMinute(String time, int minute)

Here you can find the source of getTimeAddMinute(String time, int minute)

Description

get Time Add Minute

License

Open Source License

Declaration

public static String getTimeAddMinute(String time, int minute) 

Method Source Code

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

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

public class Main {
    private static Calendar ca = Calendar.getInstance();

    public static String getTimeAddMinute(String time, int minute) {
        ca.setTime(stdt(time));//from  w ww  .  j a  v a2s .c  o m
        ca.add(Calendar.MINUTE, minute);
        return dtts(ca.getTime());
    }

    public static Date getTimeAddMinute(Date time, int minute) {
        ca.setTime(time);
        ca.add(Calendar.MINUTE, minute);
        return ca.getTime();
    }

    public static Date stdt(String str) {
        String _pattern = "yyyy-MM-dd HH:mm:ss";
        return std(str, _pattern);
    }

    public static String dtts(Date date) {
        String _pattern = "yyyy-MM-dd HH:mm:ss";
        return date == null ? null : dts(date, _pattern);
    }

    public static Date std(String str, String pattern) {
        Date dateTime = null;
        try {
            if (str != null && !str.equals("")) {
                SimpleDateFormat formater = new SimpleDateFormat(pattern);
                dateTime = formater.parse(str);
            }
        } catch (Exception ex) {
        }
        return dateTime;
    }

    public static Date std(String str) {
        String _pattern = "yyyy-MM-dd";
        return std(str, _pattern);
    }

    public static String dts(Date date, String pattern) {
        String strDateTime = null;
        SimpleDateFormat formater = new SimpleDateFormat(pattern);
        strDateTime = date == null ? null : formater.format(date);
        return strDateTime;
    }

    public static String dts(Date date) {
        String _pattern = "yyyy-MM-dd";
        return date == null ? null : dts(date, _pattern);
    }
}

Related

  1. getCurrCustomMinuteDate(String formatStr, int changeMinute)
  2. getForwardTimeByMinute(int minute, String format)
  3. getFutureDate(int _minutes)
  4. getIntevalMinutes(String startDate, String endDate)
  5. getTime(int minuteDelt)
  6. getTimeInDate(int offSetInMinutes)
  7. getTravelTimeinMinutes(String startTime, String endTime)
  8. minusMinutes(String s, long minutes)
  9. minuteBetween(Date smdate, Date bdate)