Here you can find the source of addDayOffset(final Calendar date, long offset)
private static Calendar addDayOffset(final Calendar date, long offset)
//package com.java2s; /*// ww w .j a v a 2s .com * * Copyright (c) 2011 by Jgility Development Group * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Karsten Schulz * */ import java.util.Calendar; import java.util.GregorianCalendar; public class Main { private static Calendar addDayOffset(final Calendar date, long offset) { Calendar newDate = new GregorianCalendar(); newDate.setTimeInMillis(date.getTimeInMillis()); newDate.add(Calendar.DAY_OF_MONTH, safeLongToInt(offset)); return newDate; } private static int safeLongToInt(long l) { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); } return (int) l; } }