Here you can find the source of toDateProgression(int year, int month, int day, String seed, int pedometer)
public static String toDateProgression(int year, int month, int day, String seed, int pedometer) throws Exception
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { private Calendar calendar; private static final String COLON = ":"; private static final String ZERO = "0"; public static String toDateProgression(int year, int month, int day, String seed, int pedometer) throws Exception { GregorianCalendar dateAntetype = new GregorianCalendar(year, month - 1, day); if ("year".equals(seed)) dateAntetype.add(GregorianCalendar.YEAR, pedometer); else if ("month".equals(seed)) dateAntetype.add(GregorianCalendar.MONTH, pedometer); else if ("day".equals(seed)) dateAntetype.add(GregorianCalendar.DATE, pedometer); Date d = dateAntetype.getTime(); DateFormat df = DateFormat.getDateInstance(); return df.format(d); }/*from w ww. j av a 2 s .co m*/ public String getTime() { return getHour() + COLON + getMinute(); } public int getHour() { return calendar.get(Calendar.HOUR_OF_DAY); } public String getMinute() { int tempMinute = calendar.get(Calendar.MINUTE); return tempMinute < 10 ? ZERO + tempMinute : Integer.toString(tempMinute); } }