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 Bundle bundleCalendar(Calendar cal) {
    Bundle args = new Bundle();
    if (cal == null)
        cal = Calendar.getInstance(Locale.getDefault());
    ;// www .  j  av  a 2 s. co  m
    args.putInt("year", cal.get(Calendar.YEAR));
    args.putInt("month", cal.get(Calendar.MONTH));
    args.putInt("day", cal.get(Calendar.DAY_OF_MONTH));
    args.putInt("hour", cal.get(Calendar.HOUR_OF_DAY));
    args.putInt("minute", cal.get(Calendar.MINUTE));
    return args;
}

From source file:Main.java

public static boolean isCheckChangePermitted(Context context, Calendar date) {

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    String limitActivePref = sharedPrefs.getString("active-date-key", "ALLOW_ALL");

    Calendar today = Calendar.getInstance();
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);

    Calendar yesterday;/*  w w  w  . j a  v  a 2 s  .c o m*/

    switch (limitActivePref) {
    case "ALLOW_CURRENT":
        return (date.compareTo(today) == 0);
    case "ALLOW_CURRENT_AND_NEXT_DAY":
        yesterday = (Calendar) today.clone();
        yesterday.add(Calendar.DATE, -1);
        return (date.compareTo(yesterday) >= 0);
    case "ALLOW_CURRENT_AND_NEXT_DAY_AND_WEEKEND":
        yesterday = (Calendar) today.clone();
        yesterday.add(Calendar.DATE, today.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY ? -2 : -1);
        return (date.compareTo(yesterday) >= 0);
    case "ALLOW_ALL":
    default:
        return true;
    }
}

From source file:Main.java

public static void previousDateString(String dateString) throws ParseException {
    DateFormat inputDateFormat = new SimpleDateFormat("dd-MM-yyyy");
    DateFormat outputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    Calendar now = Calendar.getInstance();
    Calendar calendar = Calendar.getInstance();
    Date myDate = inputDateFormat.parse(dateString);
    calendar.setTime(myDate);//  ww  w. j  av a  2  s. c om
    calendar.set(Calendar.HOUR_OF_DAY, now.get(Calendar.HOUR_OF_DAY));
    calendar.set(Calendar.MINUTE, now.get(Calendar.MINUTE));

    String output = outputDateFormat.format(calendar.getTime());
    System.out.println(output);
}

From source file:Main.java

public static Date getFetchDelayDate(Date startDate, Integer dateDelayMinutes) {
    Calendar c = Calendar.getInstance();
    c.setTime(startDate);/*from  www  . j a  va2s .  c  o  m*/
    if (dateDelayMinutes > 0) {
        dateDelayMinutes = -dateDelayMinutes;
    }
    c.add(Calendar.MINUTE, dateDelayMinutes);
    return c.getTime();
}

From source file:Main.java

public static LinkedHashMap<String, Integer> getDateMap(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);/*from w w w. j  a  va 2 s .c o  m*/
    LinkedHashMap<String, Integer> datemap = new LinkedHashMap<String, Integer>();
    datemap.put("year", cal.get(Calendar.YEAR));
    datemap.put("month", cal.get(Calendar.MONTH));
    datemap.put("day", cal.get(Calendar.DAY_OF_MONTH));
    datemap.put("hour", cal.get(Calendar.HOUR_OF_DAY));
    datemap.put("minute", cal.get(Calendar.MINUTE));
    datemap.put("second", cal.get(Calendar.SECOND));
    datemap.put("millisecond", cal.get(Calendar.MILLISECOND));

    return datemap;

}

From source file:Main.java

public static String ArrivalTime(long arrivalMilliseconds, String timeformat) {

    DateFormat formatter;// www. j av a2  s  . c  om
    Date convertedDate = null;

    Calendar calendarToday = Calendar.getInstance();
    calendarToday.setTimeInMillis(arrivalMilliseconds);

    String Time = String
            .valueOf(calendarToday.get(Calendar.HOUR_OF_DAY) + ":" + calendarToday.get(Calendar.MINUTE));
    formatter = new SimpleDateFormat("HH:mm");
    try {
        convertedDate = (Date) formatter.parse(Time);

    } catch (ParseException e) {
        //e.printStackTrace();
    }

    if (timeformat.equals("24"))
        return formatter.format(convertedDate);
    else
        return ampmChanger(formatter.format(convertedDate));

}

From source file:Main.java

public static String getTime(long time) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(time);//from   w  w  w . j av a  2  s  . c o  m
    int minute = c.get(Calendar.MINUTE);
    int second = c.get(Calendar.SECOND);
    String times = "";
    if (minute < 10) {
        times = "0" + minute;
    } else {
        times = "" + minute;
    }
    if (second < 10) {
        times += ":0" + second;
    } else {
        times += ":" + second;
    }
    return times;
}

From source file:Main.java

public static String getCurrentTimeStampDD_MM_HH_MM() {
    Calendar cal = new GregorianCalendar();
    return makeTimeString(cal.get(Calendar.DAY_OF_MONTH), 2) + "."
            + makeTimeString(cal.get(Calendar.MONTH) + 1, 2) + ". "
            + makeTimeString(cal.get(Calendar.HOUR_OF_DAY), 2) + ":"
            + makeTimeString(cal.get(Calendar.MINUTE), 2);
}

From source file:Main.java

/**
 * yyyyMMddHHmmss//from  w  w w  .j a va 2s.  co  m
 */
public static String getFormatTime3(Calendar c) {
    DecimalFormat df = new DecimalFormat("00");
    String strFileName = c.get(Calendar.YEAR) + df.format((c.get(Calendar.MONTH) + 1))
            + df.format(c.get(Calendar.DAY_OF_MONTH)) + df.format(c.get(Calendar.HOUR_OF_DAY))
            + df.format(c.get(Calendar.MINUTE)) + df.format(c.get(Calendar.SECOND));

    return strFileName;
}

From source file:Main.java

public static String getCurrentTimeStamp() {
    Calendar cal = new GregorianCalendar();
    return makeTimeString(cal.get(Calendar.DAY_OF_MONTH), 2) + "."
            + makeTimeString(cal.get(Calendar.MONTH) + 1, 2) + "." + makeTimeString(cal.get(Calendar.YEAR), 4)
            + " " + makeTimeString(cal.get(Calendar.HOUR_OF_DAY), 2) + ":"
            + makeTimeString(cal.get(Calendar.MINUTE), 2) + ":" + makeTimeString(cal.get(Calendar.SECOND), 2);
}