Get date After Date in MM-dd format - Android java.util

Android examples for java.util:Date Format

Description

Get date After Date in MM-dd format

Demo Code


//package com.java2s;

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

public class Main {
    public static String dateAfter3(String datestring, int after) {
        String afterDateString = "";
        Date date = null;//from   ww  w . j  av  a2s .co m
        SimpleDateFormat df = new SimpleDateFormat("MM-dd");
        try {
            date = df.parse(datestring);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.add(Calendar.DAY_OF_MONTH, after);
            date = calendar.getTime();
            afterDateString = df.format(date);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return afterDateString;
    }
}

Related Tutorials