get Add Day to Date - Android java.util

Android examples for java.util:Day

Description

get Add Day to Date

Demo Code


//package com.java2s;

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

public class Main {
    public static String fm5 = "yyyy-MM-dd";

    public static String getAddDay(String date, int addDay) {
        SimpleDateFormat formatDate = new SimpleDateFormat(fm5);
        Date d;//from   www. j  a va 2s  .  c  om
        Calendar c = Calendar.getInstance();
        try {
            d = formatDate.parse(date);
            c.setTime(d);
            c.add(Calendar.DATE, addDay);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return formatDate.format(c.getTime());
    }
}

Related Tutorials