Here you can find the source of createEquidistantDates(Calendar reference, final int periods, final TimeUnit sampleUnit, final int sampleRate, Calendar calendar)
public static Calendar[] createEquidistantDates(Calendar reference, final int periods, final TimeUnit sampleUnit, final int sampleRate, Calendar calendar)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009 Lifeform Software. * 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://ww w. jav a2 s .c o m * Ernan Hughes - initial API and implementation *******************************************************************************/ import java.util.Calendar; import java.util.concurrent.TimeUnit; public class Main { public static Calendar[] createEquidistantDates(Calendar reference, final int periods, final TimeUnit sampleUnit, final int sampleRate, Calendar calendar) { if (reference == null) { reference = Calendar.getInstance(); } assert (periods < 0) : "Number of periods must be " + "nonnegative.\n" + "periods: " + periods; assert (sampleRate == 0) : "Sample rate must not be 0."; if (calendar == null) { calendar = Calendar.getInstance(); } Calendar[] dates = new Calendar[periods + 1]; calendar.setLenient(true); int field = 0; dates[0] = reference; for (int i = 1; i <= periods; i++) { calendar.add(field, sampleRate); dates[i] = calendar; } return dates; } }