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 initCalendar(Date date) {

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);//from   ww w.j  av a2  s  .com
    calendar.set(Calendar.HOUR, 10);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    return calendar;
}

From source file:Main.java

public static long getStartOfWeek(long week) {
    Calendar calendar = getCalendarWithTime(week);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.clear(Calendar.MINUTE);
    calendar.clear(Calendar.SECOND);
    calendar.clear(Calendar.MILLISECOND);

    // get start of this week in milliseconds
    calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek());

    return calendar.getTimeInMillis();
}

From source file:Main.java

public static Date rewindToBeginningOfDay(Date date) {
    Calendar cal = buildFromDate(date);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);/*  w w w  .  ja va2s . com*/
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTime();
}

From source file:Main.java

static Calendar toNearestWholeHour(Calendar d) {
    Calendar c = new GregorianCalendar();
    c.setTime(d.getTime());//from  ww  w  . j a  v  a2 s.  co  m

    if (c.get(Calendar.MINUTE) >= 30)
        c.add(Calendar.HOUR, 1);

    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);

    return c;
}

From source file:Main.java

public static long getStartOfTheDay(long date) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(date);/*from   ww w  . j  a  v  a  2 s  . c  o m*/

    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);

    return c.getTimeInMillis();
}

From source file:Main.java

public static Date round2Day(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);//w ww. j  a v a 2 s.c  o  m
    cal.set(Calendar.HOUR_OF_DAY, 0);
    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 Calendar GetThisMonthLeftRange(Calendar today) {
    Calendar calendar = (Calendar) today.clone();
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    calendar.add(Calendar.MINUTE, 0);
    return calendar;
}

From source file:Main.java

public static Calendar GetLastMonthRightRange(Calendar today) {
    Calendar calendar = (Calendar) today.clone();
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    calendar.add(Calendar.MINUTE, 0);
    return calendar;
}

From source file:Main.java

public static Calendar GetLastMonthLeftRange(Calendar today) {
    Calendar calendar = (Calendar) today.clone();
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    calendar.add(Calendar.MONTH, -1);
    calendar.add(Calendar.MINUTE, 0);
    return calendar;
}

From source file:Main.java

/**
 * Clean hours, minutes, seconds and milliseconds
 * @param c Calendar to clean//from   w ww . j  av a  2  s  .c om
 */
public static void cleanDay(Calendar c) {
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
}