Android Minute Get getMinutesSinceStartOfDay()

Here you can find the source of getMinutesSinceStartOfDay()

Description

get Minutes Since Start Of Day

Declaration

public static int getMinutesSinceStartOfDay() 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {
    public static int getMinutesSinceStartOfDay() {
        Calendar c = Calendar.getInstance();
        int hours = c.get(Calendar.HOUR);
        int ampm = c.get(Calendar.AM_PM);

        if (ampm == Calendar.PM) {
            hours += 12;// www .j a  v  a 2s  .  c  om
        }

        int minutes = c.get(Calendar.MINUTE);

        return hours * 60 + minutes;
    }

    public static int getMinutesSinceStartOfDay(long milliseconds) {
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(milliseconds);

        int hours = c.get(Calendar.HOUR);
        int ampm = c.get(Calendar.AM_PM);

        if (ampm == Calendar.PM) {
            hours += 12;
        }

        int minutes = c.get(Calendar.MINUTE);

        return hours * 60 + minutes;
    }
}

Related

  1. getMinute()