Here you can find the source of diffDay(Calendar calendar, int day)
public static Calendar diffDay(Calendar calendar, int day)
//package com.java2s; /*!//from ww w. j a va2 s .c o m * mifmi-commons4j * https://github.com/mifmi/mifmi-commons4j * * Copyright (c) 2015 mifmi.org and other contributors * Released under the MIT license * https://opensource.org/licenses/MIT */ import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { public static long diffDay(long date, int day, TimeZone timeZone, Locale locale) { return diff(date, 0, 0, day, 0, 0, 0, 0, timeZone, locale); } public static Date diffDay(Date date, int day, TimeZone timeZone, Locale locale) { return diff(date, 0, 0, day, 0, 0, 0, 0, timeZone, locale); } public static Calendar diffDay(Calendar calendar, int day) { return diff(calendar, 0, 0, day, 0, 0, 0, 0); } public static long diff(long date, int year, int month, int day, int hour, int minute, int second, int milliSecond, TimeZone timeZone, Locale locale) { Calendar calendar = getCalendar(timeZone, locale); calendar.setTimeInMillis(date); calendar = diff(calendar, year, month, day, hour, minute, second, milliSecond); return calendar.getTimeInMillis(); } public static Date diff(Date date, int year, int month, int day, int hour, int minute, int second, int milliSecond, TimeZone timeZone, Locale locale) { Calendar calendar = getCalendar(timeZone, locale); calendar.setTime(date); calendar = diff(calendar, year, month, day, hour, minute, second, milliSecond); return calendar.getTime(); } public static Calendar diff(Calendar calendar, int year, int month, int day, int hour, int minute, int second, int milliSecond) { calendar.add(Calendar.MILLISECOND, milliSecond); calendar.add(Calendar.SECOND, second); calendar.add(Calendar.MINUTE, minute); calendar.add(Calendar.HOUR, hour); calendar.add(Calendar.DAY_OF_MONTH, day); calendar.add(Calendar.MONTH, month); calendar.add(Calendar.YEAR, year); return calendar; } public static Calendar getCalendar(TimeZone timeZone, Locale locale) { Calendar cal; if (timeZone == null) { if (locale == null) { cal = Calendar.getInstance(); } else { cal = Calendar.getInstance(locale); } } else { if (locale == null) { cal = Calendar.getInstance(timeZone); } else { cal = Calendar.getInstance(timeZone, locale); } } return cal; } }