Java Date to Minute getMinutes(Date d)

Here you can find the source of getMinutes(Date d)

Description

get Minutes

License

Open Source License

Declaration

public static int getMinutes(Date d) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static int getMinutes(Date d) {
        Calendar c = getCalendar();
        c.setTime(d);//from w w w  .j a  v  a 2s .c om
        return (c.get(Calendar.MINUTE));
    }

    /**
     * month ranges from 1 to 12 (not 0 to 11)
     */
    private static Calendar getCalendar() {
        return (getCalendar(null, null));
    }

    private static Calendar getCalendar(TimeZone timeZone, Locale locale) {
        if (timeZone == null)
            timeZone = TimeZone.getDefault();

        if (locale == null)
            locale = Locale.getDefault();

        Calendar c = new GregorianCalendar(timeZone, locale);
        return (c);
    }

    public static Date setTime(Date d, long time) {
        d.setTime(time);
        return (d);
    }
}

Related

  1. getMinute(Date d)
  2. getMinute(Date date)
  3. getMinute(Date date)
  4. getMinute(java.util.Date date)
  5. getMinuteOfHour(final Date date)
  6. getMinutes(Date time)
  7. getMinutes(final Date date)
  8. getMinutesInDay(Date d)
  9. getMinutesOfHour(Date dt)