Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.util.Log;

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

public class Main {
    public static Calendar getFinishDate(String startDate, String duration) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
            Calendar calendarFinish = Calendar.getInstance();
            calendarFinish.setTime(sdf.parse(startDate));
            calendarFinish.add(Calendar.DATE, Integer.parseInt(duration));
            return calendarFinish;
        } catch (ParseException e) {
            Log.e("PARSE_FAIL", Log.getStackTraceString(e));
        }
        return null;
    }
}