Example usage for java.util Calendar MINUTE

List of usage examples for java.util Calendar MINUTE

Introduction

In this page you can find the example usage for java.util Calendar MINUTE.

Prototype

int MINUTE

To view the source code for java.util Calendar MINUTE.

Click Source Link

Document

Field number for get and set indicating the minute within the hour.

Usage

From source file:Main.java

public static Calendar clearTime(Calendar calendar) {
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    return calendar;
}

From source file:Main.java

private static Date get2MinsAgo() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MINUTE, -2);

    return calendar.getTime();
}

From source file:Main.java

public static long today9am() {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, 9);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);/*from   www. j av a 2s.c om*/
    c.set(Calendar.MILLISECOND, 0);
    return c.getTimeInMillis();
}

From source file:Main.java

public static Calendar getNextStart() {
    Calendar cc = Calendar.getInstance();
    cc.roll(Calendar.HOUR, 1);// w w w.j  ava 2  s  .  co m
    cc.set(Calendar.MINUTE, 0);
    cc.set(Calendar.SECOND, 0);
    return cc;
}

From source file:Main.java

public static Calendar roundMinutesAndHour(Calendar time, int TIME_PICKER_INTERVAL) {
    int minute = time.get(Calendar.MINUTE);
    int hour = time.get(Calendar.HOUR_OF_DAY);

    if (time.get(Calendar.MINUTE) % TIME_PICKER_INTERVAL != 0) {
        int minuteFloor = minute - (minute % TIME_PICKER_INTERVAL);
        minute = minuteFloor + (minute == minuteFloor + 1 ? TIME_PICKER_INTERVAL : 0);
        if (minute == 60) {
            hour++;/* w  w  w.  j a v  a 2s  . c o  m*/
            minute = 0;
        }
    }

    time.set(Calendar.HOUR_OF_DAY, hour);
    time.set(Calendar.MINUTE, minute);
    return time;
}

From source file:Main.java

public static long getSmallHourTimestamp() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR, 0);/* w w  w  .  j  a  va 2s . com*/
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static void copyTime(Calendar dest, Calendar src) {
    dest.set(Calendar.HOUR_OF_DAY, src.get(Calendar.HOUR_OF_DAY));
    dest.set(Calendar.MINUTE, src.get(Calendar.MINUTE));
    dest.set(Calendar.SECOND, src.get(Calendar.SECOND));
    dest.set(Calendar.MILLISECOND, src.get(Calendar.MILLISECOND));
}

From source file:Main.java

public static int getMinute(Date date) {
    return getCalendar(date).get(Calendar.MINUTE);
}

From source file:Main.java

public static void toBeginOfDay(Calendar cal) {
    cal.set(Calendar.HOUR_OF_DAY, 0); // ! clear would not reset the hour of day !
    cal.clear(Calendar.MINUTE);
    cal.clear(Calendar.SECOND);//from   w  ww  .  j a v  a2  s . c  o  m
    cal.clear(Calendar.MILLISECOND);
}

From source file:Main.java

public static String toTimeString(Calendar date) {
    String hour = "" + date.get(Calendar.HOUR_OF_DAY);
    String minute = "" + date.get(Calendar.MINUTE);

    if (minute.length() == 1)
        minute = "0" + minute;

    return hour + ":" + minute;
}