Here you can find the source of addOneDay(String strDate)
public static String addOneDay(String strDate)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static final String _DEFAULT1 = "yyyy-MM-dd HH:mm"; public static final String _DEFAULT4 = "yyyy-MM-dd"; public static String addOneDay(String strDate) { // YYYY-MM-DD int[] standardDays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int[] leapyearDays = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int y = Integer.parseInt(strDate.substring(0, 4)); int m = Integer.parseInt(strDate.substring(4, 6)); int d = Integer.parseInt(strDate.substring(6, 8)) + 1; int maxDateCount = 0; System.out.println(y);/*from w ww . j av a 2 s . com*/ System.out.println(m); System.out.println(d); if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) { maxDateCount = leapyearDays[m - 1]; } else { maxDateCount = standardDays[m - 1]; } if (d > maxDateCount) { d = 1; m++; } if (m > 12) { m = 1; y++; } java.text.DecimalFormat yf = new java.text.DecimalFormat("0000"); java.text.DecimalFormat mdf = new java.text.DecimalFormat("00"); return yf.format(y) + mdf.format(m) + mdf.format(d); } public static String format(Date date) { return formatDate(date, _DEFAULT4); } public static String formatDate(Date date) { return formatDate(date, _DEFAULT1); } public static String formatDate(Date date, String style) { return new SimpleDateFormat(style).format(date); } }