Java Hour getHourOfDayInAm(Date dt)

Here you can find the source of getHourOfDayInAm(Date dt)

Description

Returns an hour in AM

License

Open Source License

Parameter

Parameter Description
dt a parameter

Declaration

public static int getHourOfDayInAm(Date dt) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    /**/*from   ww  w .  ja  v a2 s  .c o m*/
     * Returns an hour in AM
     * 
     * @param dt
     * @return
     */
    public static int getHourOfDayInAm(Date dt) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(dt);
        int hour = cal.get(Calendar.HOUR_OF_DAY);
        if (hour > 12) {
            hour = hour - 12;
        }
        return hour;
    }
}

Related

  1. getHourMinuteSecondByMisSecond(long misSecond)
  2. getHourMinuteString(Date dateTime)
  3. getHourMinuteString(Date t)
  4. getHourOfDay(Calendar date)
  5. getHourOfDay(final Date date)
  6. getHourOfWeek(Date dateIn)
  7. getHours()
  8. getHours()
  9. getHours(Date t, Date baseDate)