Here you can find the source of millisFromEpochToHourId(long millis, TimeZone tz)
Parameter | Description |
---|---|
millis | input millis |
tz | the timezone |
public static int millisFromEpochToHourId(long millis, TimeZone tz)
//package com.java2s; /**//from w w w.ja va 2 s. c o m * Copyright 2012 Twitter, Inc. * * 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.Calendar; import java.util.TimeZone; public class Main { /** * Convert from millis to hour id * @param millis input millis * @param tz the timezone * @return the hour id */ public static int millisFromEpochToHourId(long millis, TimeZone tz) { Calendar cal = Calendar.getInstance(tz); cal.setTimeInMillis(millis); return calendarToHourId(cal); } /** * Convert a calendar to an hour id * @param cal the calendar * @return the hour id */ public static int calendarToHourId(Calendar cal) { return cal.get(Calendar.HOUR_OF_DAY); } }