Java Date Add dateAddMM(Date date, int i)

Here you can find the source of dateAddMM(Date date, int i)

Description

date Add MM

License

Apache License

Declaration

public static String dateAddMM(Date date, int i) 

Method Source Code

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

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

public class Main {
    public final static String DATETIME_FORMAT_YYYYMMDDHHMMSS = "yyyyMMddHHmmss";

    public static String dateAddMM(Date date, int i) {
        Date currTime = addMM(date, i);
        SimpleDateFormat format = new SimpleDateFormat(DATETIME_FORMAT_YYYYMMDDHHMMSS);
        return format.format(currTime);
    }//from w w w .  ja v  a 2  s .c  o  m

    public static Date addMM(Date date, int i) {
        if (date == null)
            return null;
        Calendar c = new GregorianCalendar();
        c.setTime(date);
        c.add(Calendar.MINUTE, i);
        return c.getTime();
    }

    public static String addMM(int i) {
        Date currTime = addMM(getNowDate(), i);
        SimpleDateFormat format = new SimpleDateFormat(DATETIME_FORMAT_YYYYMMDDHHMMSS);
        return format.format(currTime);
    }

    public static Date getNowDate() {
        Calendar c = Calendar.getInstance();
        return c.getTime();
    }
}

Related

  1. dateAddDays(Date date, int days)
  2. dateAddDays(Date date, int days)
  3. dateAddDays(Date time, int days, String dateFormat)
  4. dateAddHours(Date time, int hours, SimpleDateFormat dateFormat)
  5. dateAddMinutes(Date date, int minutes)
  6. dateAddMonths(Date date, int addMonths)
  7. dateAddSpaceMilliSecond(Date date, int milliSecond)