Here you can find the source of getHourOfDayInAm(Date dt)
Parameter | Description |
---|---|
dt | a parameter |
public static int getHourOfDayInAm(Date dt)
//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; } }