Java Month of Year getNextiMonth(Date date, int month)

Here you can find the source of getNextiMonth(Date date, int month)

Description

get Nexti Month

License

Open Source License

Declaration

public static String getNextiMonth(Date date, int month) 

Method Source Code


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

import java.text.DateFormat;

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

public class Main {
    public static String getNextiMonth(Date date, int month) {
        Calendar c = Calendar.getInstance();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        c.setTime(new Date());
        c.add(Calendar.DATE, month);
        Date d2 = c.getTime();/* w ww.  j a  v a  2 s  . co  m*/
        String s = df.format(d2);
        return s;
    }

    public static String getTime() {

        Calendar calendar = Calendar.getInstance();

        String strHour = "" + calendar.get(Calendar.HOUR_OF_DAY);

        if (strHour.length() == 1)

            strHour = "0" + strHour;

        String strMinute = "" + calendar.get(Calendar.MINUTE);

        if (strMinute.length() == 1)

            strMinute = "0" + strMinute;

        String strSecond = "" + calendar.get(Calendar.SECOND);

        if (strSecond.length() == 1)

            strSecond = "0" + strSecond;

        String curTime = strHour + strMinute + strSecond;

        return curTime;

    }
}

Related

  1. getMonthHaveDays(int year, int month)
  2. getMonthOfYear(int m)
  3. getMonthOfYear(long time)
  4. getMonthOfYearFromTimestamp(long ms)
  5. getMonthStart(int year, int month)
  6. getNextMonth()
  7. getNextMonth(Calendar aCal)
  8. getNextMonth(Date nowdate, int delay)
  9. getNextMonthFirstDay(String date)