Java Hour getHour12(Date date)

Here you can find the source of getHour12(Date date)

Description

Return hour12.

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static int getHour12(Date date) 

Method Source Code

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

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static final Locale LOCALE_DEFAULT = Locale.getDefault();

    public static int getHour12(Date date) {
        return getCalendar(date).get(Calendar.HOUR);
    }//from www .  ja  v a 2  s . c  o  m

    public static Calendar getCalendar() {
        return Calendar.getInstance();
    }

    public static Calendar getCalendar(Date datetime) {
        return getCalendar(datetime, LOCALE_DEFAULT);
    }

    public static Calendar getCalendar(Date datetime, Locale locale) {
        Calendar cal = Calendar.getInstance(locale);
        cal.setTime(datetime);
        return cal;
    }
}

Related

  1. getHour(final Date timeFrom)
  2. getHour(java.util.Date date)
  3. getHour(long t)
  4. getHour(String dateString)
  5. getHour(String dateTime)
  6. getHourAfter(Date date, int hour)
  7. getHourAfter(final Date _from, final int _hours)
  8. getHourAndMin(long time)
  9. getHourAndMinutes(Date dt)