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

static void setDate(Calendar cal, int month, int date) {
    cal.clear();//from   w  w  w .j av  a 2s.com

    cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR));
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DATE, date);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
}

From source file:Main.java

/**
 * //from  w  w  w  .  j av a  2s . com
 * @return Minute within current hour
 */
public static int getCurrentMinutes() {
    return Calendar.getInstance().get(Calendar.MINUTE);
}

From source file:Main.java

static Calendar toNextWholeHour(Calendar d) {
    Calendar c = new GregorianCalendar();
    c.setTime(d.getTime());/*from w w w . jav  a 2  s  . c  om*/
    c.add(Calendar.HOUR, 1);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    return c;
}

From source file:Main.java

public static void moveToCalendarHourTerminal(Calendar cal) { // 2011/11/17 11:59:59.999
    moveToCalendarMinute(cal, cal.getActualMaximum(Calendar.MINUTE));
    moveToCalendarMinuteTerminal(cal);//w  ww . j a  va 2  s .  c  o m
}

From source file:Main.java

public static Date getFloorDate(Date d) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(d);//  www . j a  v  a  2s .  c om

    // Set time fields to zero
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);

    return cal.getTime();
}

From source file:Main.java

public static String createJcFileName() {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(System.currentTimeMillis());

    int y = c.get(Calendar.YEAR);
    int m = c.get(Calendar.MONTH);
    int d = c.get(Calendar.DAY_OF_MONTH);
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);
    int second = c.get(Calendar.SECOND);
    return y + "-" + m + "-" + d + "-" + hour + "-" + minute + "-" + second;
}

From source file:Main.java

public static Date getCeilDate(Date d) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date(d.getTime() + 1000 * 60 * 60));

    // Set time fields to zero
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);/*from  w  ww. ja  v  a 2s.  c  om*/
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTime();

}

From source file:Main.java

public static long getTodayZeroTimeInMillis() {
    Calendar calendar = getZeroSecondCalendar();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    return calendar.getTimeInMillis();
}

From source file:Main.java

static void setDate(Calendar cal, int month, int date, boolean endOfDay) {
    cal.clear();/*from   www .j  ava 2  s.  c om*/
    cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR));
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DATE, date);
    if (endOfDay) {
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        cal.set(Calendar.MILLISECOND, 999);
    } else {
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
    }
}

From source file:Main.java

public static void trimTimestamp(Calendar cal) {
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);/*w  w w.jav a2s .  co  m*/
    cal.set(Calendar.MILLISECOND, 0);
}