Android Calendar Add getFormatCurrentAdd(int amount, String format)

Here you can find the source of getFormatCurrentAdd(int amount, String format)

Description

get Format Current Add

Declaration

public static String getFormatCurrentAdd(int amount, String format) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String getFormatCurrentAdd(int amount, String format) {

        Date d = getDateAdd(new Date(), amount);

        return getFormatDateTime(d, format);
    }// w  w  w  .  ja va2 s . c  om

    public static Date getDateAdd(Date date, int amount) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(date);
        cal.add(GregorianCalendar.DATE, amount);
        return cal.getTime();
    }

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

Related

  1. after(Calendar c, long offset)
  2. afterNDays(Calendar c, int n)
  3. getDateAdd(Date date, int amount)
  4. getDateByAddFltHour(float flt)
  5. getDateByAddHour(String datetime, int minute)
  6. tomorrow(Calendar c)
  7. yesterday(Calendar c)
  8. addToCurrent(int type, int i)
  9. rollGetDate(Calendar calendar, int days)