Here you can find the source of getDays(long endTs, Long lookback)
public static List<Date> getDays(long endTs, Long lookback)
//package com.java2s; /**/* w w w .java2s .c om*/ * Copyright 2015-2016 The OpenZipkin Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import java.util.*; import java.util.concurrent.TimeUnit; public class Main { static final TimeZone UTC = TimeZone.getTimeZone("UTC"); public static List<Date> getDays(long endTs, Long lookback) { long to = midnightUTC(endTs); long from = midnightUTC(endTs - (lookback != null ? lookback : endTs)); List<Date> days = new ArrayList<>(); for (long time = from; time <= to; time += TimeUnit.DAYS.toMillis(1)) { days.add(new Date(time)); } return days; } /** For bucketed data floored to the day. For example, dependency links. */ public static long midnightUTC(long epochMillis) { Calendar day = Calendar.getInstance(UTC); day.setTimeInMillis(epochMillis); day.set(Calendar.MILLISECOND, 0); day.set(Calendar.SECOND, 0); day.set(Calendar.MINUTE, 0); day.set(Calendar.HOUR_OF_DAY, 0); return day.getTimeInMillis(); } }