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

private static Calendar clearTimes(Calendar c) {
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);//from   w w w  . ja v  a 2 s.c  o m
    c.set(Calendar.MILLISECOND, 0);
    return c;
}

From source file:Main.java

public static List<Integer> getAllDayInMonth(int month, int year) {
    List<Integer> listDate = new ArrayList<Integer>();

    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month, 1);/*from  w w  w. j a  va 2  s .co  m*/
    calendar.clear(Calendar.HOUR);
    calendar.clear(Calendar.MINUTE);
    calendar.clear(Calendar.SECOND);
    int totalDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

    for (int i = 1; i <= totalDays; i++) {
        listDate.add(i);
    }
    return listDate;
}

From source file:Main.java

public static String createCCPFileName() {
    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 Calendar transformStringTimeToCalendar(String time) {
    Calendar calendar = Calendar.getInstance();
    String[] split = time.split(":");
    if (split.length > 0) {
        calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(split[0]));
    }//from  ww  w . j  a  va2 s  .com
    if (split.length > 1) {
        calendar.set(Calendar.MINUTE, Integer.parseInt(split[1]));
    }
    if (split.length > 2) {
        calendar.set(Calendar.SECOND, Integer.parseInt(split[2]));
    }
    return calendar;
}

From source file:Main.java

public static Calendar calculateNextAlarmTime(int repetition) {
    if (repetition == 0)
        return null;
    Calendar alarmTime = Calendar.getInstance();
    alarmTime.set(Calendar.HOUR_OF_DAY, 20);
    alarmTime.set(Calendar.MINUTE, 0);
    alarmTime.set(Calendar.SECOND, 0);

    int day_of_week = alarmTime.get(Calendar.DAY_OF_WEEK) - 2;
    if (day_of_week == -1)
        day_of_week = 6;// sunday
    repetition &= 0x7f;//from   w w w  . j  ava 2  s . c  om
    int rot = (repetition >> (day_of_week + 1)) | (repetition << (7 - day_of_week - 1));
    rot &= 0x7f;
    int ndays = 0;
    for (ndays = 0; ndays < 7; ndays++) {
        if ((rot & (1 << ndays)) != 0)
            break;
    }
    alarmTime.add(Calendar.DATE, ndays + 1);

    return alarmTime;
}

From source file:Main.java

public static Date getDate(int year, int month, int day) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DAY_OF_MONTH, day);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);/*from w w w. ja va2s. c  o m*/
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTime();
}

From source file:Main.java

public static Date lastDayOfMonth(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);/*from   ww w . j a  v a2s . c o m*/
    cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH));
    cal.set(Calendar.HOUR_OF_DAY, Calendar.getInstance().getActualMaximum(Calendar.HOUR_OF_DAY));
    cal.set(Calendar.MINUTE, Calendar.getInstance().getActualMaximum(Calendar.MINUTE));
    return cal.getTime();
}

From source file:Main.java

public static Date firstDayOfMonth(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);//ww  w.j a  v  a  2  s . c  o m
    cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH));
    cal.set(Calendar.HOUR_OF_DAY, Calendar.getInstance().getActualMinimum(Calendar.HOUR_OF_DAY));
    cal.set(Calendar.MINUTE, Calendar.getInstance().getActualMinimum(Calendar.MINUTE));
    return cal.getTime();
}

From source file:Main.java

@NonNull
public static String getTime() {
    Calendar calendar = Calendar.getInstance();
    return calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-"
            + calendar.get(Calendar.DAY_OF_MONTH) + "  " + calendar.get(Calendar.HOUR_OF_DAY) + ":"
            + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);
}

From source file:Main.java

public static Date lastTimeOfMonth(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);// w  w w .j  a  v a  2s .  co  m
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
    cal.set(Calendar.HOUR_OF_DAY, cal.getActualMaximum(Calendar.HOUR_OF_DAY));
    cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE));
    cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND));
    cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND));
    return cal.getTime();
}