Java Hour getHour(long t)

Here you can find the source of getHour(long t)

Description

get Hour

License

LGPL

Declaration

public static int getHour(long t) 

Method Source Code

//package com.java2s;
/**//  w ww  . j  a va  2 s  . c  om
 * Converts a line of text into an array of lower case words using a
 * BreakIterator.wordInstance(). <p>
 *
 * This method is under the Jive Open Source Software License and was
 * written by Mark Imbriaco.
 *
 * @param text a String of text to convert into an array of words
 * @return text broken up into an array of words.
 */

import java.util.Calendar;

import java.util.Date;

public class Main {
    public static int getHour(long t) {
        Calendar cld = Calendar.getInstance();
        if (t > 0) {
            cld.setTime(new java.util.Date(t));
        }
        return cld.get(Calendar.HOUR_OF_DAY);
    }

    public static int getHour(Date date) {
        Calendar cld = Calendar.getInstance();
        cld.setTime(date);
        return cld.get(Calendar.HOUR_OF_DAY);
    }
}

Related

  1. getHour(Date date)
  2. getHour(Date date)
  3. getHour(Date now)
  4. getHour(final Date timeFrom)
  5. getHour(java.util.Date date)
  6. getHour(String dateString)
  7. getHour(String dateTime)
  8. getHour12(Date date)
  9. getHourAfter(Date date, int hour)