List of usage examples for java.util Calendar MINUTE
int MINUTE
To view the source code for java.util Calendar MINUTE.
Click Source Link
get
and set
indicating the minute within the hour. From source file:Main.java
public static Date lastTimeOfMonth(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);//from w w w. j a v a2 s . com 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(); }
From source file:Main.java
public static Date firstTimeOfMonth(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w w w . j a v a 2s .c om*/ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND)); return cal.getTime(); }
From source file:Main.java
public static String toYYYYMMDDHHMMSS(Calendar source) { if (source == null) { return "Can't toYYYYMMDDHHMMSS source null"; }//from w w w. jav a 2s . co m int YYYY = source.get(Calendar.YEAR); int MM = source.get(Calendar.MONTH); int DD = source.get(Calendar.DAY_OF_MONTH); int HH = source.get(Calendar.HOUR_OF_DAY); int mm = source.get(Calendar.MINUTE); int SS = source.get(Calendar.SECOND); return YYYY + "-" + MM + "-" + DD + " " + HH + ":" + mm + ":" + SS; }
From source file:Main.java
public static String getDateString(long millitm) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(millitm);// w w w . j a v a 2s. c o m return (setZeroPad(cal.get(Calendar.YEAR)) + "/" + setZeroPad(cal.get(Calendar.MONTH)) + "/" + setZeroPad(cal.get(Calendar.DATE)) + " " + setZeroPad(cal.get(Calendar.HOUR_OF_DAY)) + ":" + setZeroPad(cal.get(Calendar.MINUTE)) + ":" + setZeroPad(cal.get(Calendar.SECOND))); }
From source file:Main.java
public static Date buildShiftEndTime(int startHour, int startMin, int startAmPm, int endHour, int endMin, int endAmPm) { endHour = endHour == 12 ? 0 : endHour; calendar.clear();/* ww w.j a va 2 s . co m*/ calendar.set(Calendar.HOUR, endHour); calendar.set(Calendar.MINUTE, endMin); calendar.set(Calendar.AM_PM, endAmPm); if (startAmPm == Calendar.PM && endAmPm == Calendar.AM) { calendar.add(Calendar.DAY_OF_MONTH, 1); } return calendar.getTime(); }
From source file:Main.java
public static Date dayBegin(final Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);/*from w ww . j a va 2 s. c om*/ c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); }
From source file:Main.java
private static boolean isBefore(Calendar date, String time) { try {/*from w w w . j a va 2s . c o m*/ String[] arr = time.split(":"); int hours = Integer.parseInt(arr[0]); int mins = Integer.parseInt(arr[1]); return (date.get(Calendar.HOUR_OF_DAY) < hours) || (date.get(Calendar.HOUR_OF_DAY) == hours && date.get(Calendar.MINUTE) < mins); } catch (Exception e) { Log.e("Utils.java isBefore", "The supplied times are not properly formatted. Verify that your schedule times follow the hh:mm pattern"); return true; } }
From source file:Main.java
public static Date buildShiftStartTime(int startHour, int startMin, int startAmPm, int endHour, int endMin, int endAmPm) { startHour = startHour == 12 ? 0 : startHour; calendar.clear();//from w ww.j av a2s. c om calendar.set(Calendar.HOUR, startHour); calendar.set(Calendar.MINUTE, startMin); calendar.set(Calendar.AM_PM, startAmPm); return calendar.getTime(); }
From source file:Util.java
public static String formatAsMySQLDatetime(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);//from w w w. ja v a 2 s.c o m int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DATE); int hours = calendar.get(Calendar.HOUR_OF_DAY); int minutes = calendar.get(Calendar.MINUTE); int seconds = calendar.get(Calendar.SECOND); return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds; }
From source file:Main.java
public static Calendar getCalendarForTime(int repeatMode, int dayOfWeek, int hour, int minute, int second) { Calendar calendarNow = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, second); calendar.set(Calendar.MILLISECOND, 0); if (repeatMode == 2) { int dayOfWeekAndroid = 0; // 7 stands for sunday for interface, but for android, sunday stands for 1. dayOfWeekAndroid = dayOfWeek % 7 + 1; calendar.set(Calendar.DAY_OF_WEEK, dayOfWeekAndroid); }/*from w ww. j a v a 2s .c o m*/ // make sure the desire alarm time is in future. int tryCount = 0; int tryCountMax = 62; while (calendar.getTimeInMillis() < calendarNow.getTimeInMillis() && tryCount < tryCountMax) { if (repeatMode == 1) { calendar.add(Calendar.DAY_OF_YEAR, 1); } else if (repeatMode == 2) { calendar.add(Calendar.DAY_OF_YEAR, 7); } tryCount++; } Log.v("cpeng", "getCalendearForTime target info: " + calendar.toString()); return calendar; }