Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {

    public static String getNextDateByYear(String s, int i) {

        SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyyMMdd");
        java.util.Date date = simpledateformat.parse(s, new ParsePosition(0));
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.YEAR, i);
        date = calendar.getTime();
        s = simpledateformat.format(date);
        return s;
    }
}