Java TimeZone Add millisFromEpochToHourId(long millis, TimeZone tz)

Here you can find the source of millisFromEpochToHourId(long millis, TimeZone tz)

Description

Convert from millis to hour id

License

Apache License

Parameter

Parameter Description
millis input millis
tz the timezone

Return

the hour id

Declaration

public static int millisFromEpochToHourId(long millis, TimeZone tz) 

Method Source Code

//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);
    }
}

Related

  1. adjustTimeToDefaultTimezone(long time)
  2. baseFor(TimeZone tz)
  3. cal(TimeZone tz)
  4. isAfter(int month1, int day1, int year1, int hour1, int minute1, int amPm1, int month2, int day2, int year2, int hour2, int minute2, int amPm2, TimeZone timeZone, Locale locale)
  5. isFuture(int month, int year, TimeZone timeZone, Locale locale)
  6. nowWithTimeZone(TimeZone timezone)
  7. removeTimeZoneOffset(long t)
  8. shiftDate(Date date, TimeZone timeZone, String pattern)
  9. stringToCal(String s, TimeZone tz)