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 Long getIncTimeInMillis(Date originDate, int increment) {
    if (null == originDate)
        return null;
    Calendar c = Calendar.getInstance();
    c.setTime(originDate);/*from w w w. ja va2  s  . c  om*/
    c.add(Calendar.MINUTE, increment);
    return c.getTimeInMillis();
}

From source file:Main.java

public static Calendar addMinutes(long time, int minutes, int minInterval) {
    return add(time, minutes * minInterval, Calendar.MINUTE);
}

From source file:Main.java

public static long getTimeMillisAsHourAndMinute(long millis) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(millis);/*from  ww  w  .j a v a  2s. c  o m*/
    int hour = calendar.get(Calendar.HOUR_OF_DAY);
    int minute = calendar.get(Calendar.MINUTE);
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.MINUTE, minute);
    return calendar.getTimeInMillis();
}

From source file:Main.java

public static Date firstTimeOfWeek(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(date.getTime());

    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);

    Date dateBegin = new Date();
    dateBegin.setTime(calendar.getTimeInMillis());
    return dateBegin;
}

From source file:Main.java

public static Date getFetchDelayDate(Integer dateDelayMinutes) {
    Calendar c = Calendar.getInstance();
    if (dateDelayMinutes > 0) {
        dateDelayMinutes = -dateDelayMinutes;
    }/*from   ww w. j a  v  a 2s  . c  o m*/
    c.add(Calendar.MINUTE, dateDelayMinutes);
    return c.getTime();
}

From source file:Main.java

public static int daysSince(final long date) {
    final Calendar logDate = Calendar.getInstance();
    logDate.setTimeInMillis(date);//ww  w.  j  a v a  2  s .c o  m
    logDate.set(Calendar.SECOND, 0);
    logDate.set(Calendar.MINUTE, 0);
    logDate.set(Calendar.HOUR_OF_DAY, 0);
    final Calendar today = Calendar.getInstance();
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.HOUR_OF_DAY, 0);
    return (int) Math.round((today.getTimeInMillis() - logDate.getTimeInMillis()) / 86400000d);
}

From source file:Main.java

public static float getPercentOfDay() {
    GregorianCalendar cal = new GregorianCalendar();
    float dayMillis = 0;
    dayMillis += (cal.get(Calendar.HOUR_OF_DAY) * 60 * 60);
    dayMillis += (cal.get(Calendar.MINUTE) * 60);
    dayMillis += cal.get(Calendar.SECOND);
    float totalDayMillis = (24f * 60f * 60f);
    return (dayMillis / totalDayMillis);
}

From source file:Main.java

/**
 * Convert the day in calendar in the end of the day: 23:59:59.999
 * @param c Calendar to change// ww  w  . j a  v a  2  s.c o  m
 */
public static void endOfDay(Calendar c) {

    c.set(Calendar.HOUR_OF_DAY, 23);
    c.set(Calendar.MINUTE, 59);
    c.set(Calendar.SECOND, 59);
    c.set(Calendar.MILLISECOND, 999);
}

From source file:Main.java

public static void setDateTime(long timeStamp, Calendar currentCalender, int i) {
    currentCalender.setTimeInMillis(timeStamp);
    currentCalender.set(Calendar.DATE, 1);
    currentCalender.set(Calendar.HOUR_OF_DAY, 0);
    currentCalender.set(Calendar.MINUTE, 0);
    currentCalender.set(Calendar.SECOND, 0);
    currentCalender.set(Calendar.MILLISECOND, 0);
    currentCalender.add(Calendar.DATE, i);
}

From source file:Main.java

public static Date getTheEndOfDate(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);//from w  w  w .  j  a v a 2  s  .  co m
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    return calendar.getTime();
}