Here you can find the source of getYear(int num)
public static String getYear(int num)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static String getYear(int num) { Calendar calendar = new GregorianCalendar(); int year = calendar.get(Calendar.YEAR) + num; int month = calendar.get(Calendar.MONTH); String yearstr = ""; if (month < 8) { yearstr = String.valueOf(-1) + "/" + String.valueOf(year); } else {/*from w w w . j a va2s . c o m*/ yearstr = String.valueOf(year) + "/" + String.valueOf(year + 1); } return yearstr; } public static String getYear(Date parseDate) { if (parseDate == null) { return getYear(0); } String result = ""; Calendar calendar = Calendar.getInstance(); calendar.setTime(parseDate); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); if (month < 8) { result = String.valueOf(year - 1) + "/" + String.valueOf(year); } else { result = String.valueOf(year) + "/" + String.valueOf(year + 1); } return result; } }