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:is.idega.idegaweb.egov.gumbo.licenses.SetDraganotveidiValidPeriod.java
public void execute(ExecutionContext executionContext) throws Exception { final Interval period; final Calendar now = Calendar.getInstance(); now.set(Calendar.HOUR, 0);//w ww . j a v a 2 s. com now.set(Calendar.MINUTE, 0); now.set(Calendar.SECOND, 0); now.set(Calendar.MILLISECOND, 0); final Calendar mayStart = Calendar.getInstance(); mayStart.set(now.get(Calendar.YEAR), Calendar.MAY, 1, 0, 0, 0); final Calendar augEnd = Calendar.getInstance(); augEnd.set(now.get(Calendar.YEAR), Calendar.AUGUST, 31, 0, 0, 0); if (now.after(mayStart) && now.before(augEnd)) { period = new Interval(now.getTime(), augEnd.getTime()); } else { period = findNearestPeriod(now); } executionContext.setVariable("date_validityFrom", period.getFrom()); executionContext.setVariable("date_validityTo", period.getTo()); }
From source file:AIR.Common.Utilities.Dates.java
/** * @param date//w ww. j av a 2s .c o m * @return returns the midnight time for this date e.g. if date is * "10/11/2012 12:10 pm" then this will return "10/11/2012 00:00 am" */ public static Date getStartOfDayDate(Date date) { Calendar calendarInstance = Calendar.getInstance(); calendarInstance.setTime(date); calendarInstance.set(Calendar.HOUR_OF_DAY, 0); calendarInstance.set(Calendar.MINUTE, 0); calendarInstance.set(Calendar.SECOND, 0); return calendarInstance.getTime(); }
From source file:Main.java
/** * Given a calendar (possibly containing only a day of the year), returns the earliest possible * anniversary of the date that is equal to or after the current point in time if the date * does not contain a year, or the date converted to the local time zone (if the date contains * a year.//from www.ja va 2s . c o m * * @param target The date we wish to convert(in the UTC time zone). * @return If date does not contain a year (year < 1900), returns the next earliest anniversary * that is after the current point in time (in the local time zone). Otherwise, returns the * adjusted Date in the local time zone. */ public static Date getNextAnnualDate(Calendar target) { final Calendar today = Calendar.getInstance(); today.setTime(new Date()); // Round the current time to the exact start of today so that when we compare // today against the target date, both dates are set to exactly 0000H. today.set(Calendar.HOUR_OF_DAY, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); final boolean isYearSet = isYearSet(target); final int targetYear = target.get(Calendar.YEAR); final int targetMonth = target.get(Calendar.MONTH); final int targetDay = target.get(Calendar.DAY_OF_MONTH); final boolean isFeb29 = (targetMonth == Calendar.FEBRUARY && targetDay == 29); final GregorianCalendar anniversary = new GregorianCalendar(); // Convert from the UTC date to the local date. Set the year to today's year if the // there is no provided year (targetYear < 1900) anniversary.set(!isYearSet ? today.get(Calendar.YEAR) : targetYear, targetMonth, targetDay); // If the anniversary's date is before the start of today and there is no year set, // increment the year by 1 so that the returned date is always equal to or greater than // today. If the day is a leap year, keep going until we get the next leap year anniversary // Otherwise if there is already a year set, simply return the exact date. if (!isYearSet) { int anniversaryYear = today.get(Calendar.YEAR); if (anniversary.before(today) || (isFeb29 && !anniversary.isLeapYear(anniversaryYear))) { // If the target date is not Feb 29, then set the anniversary to the next year. // Otherwise, keep going until we find the next leap year (this is not guaranteed // to be in 4 years time). do { anniversaryYear += 1; } while (isFeb29 && !anniversary.isLeapYear(anniversaryYear)); anniversary.set(anniversaryYear, targetMonth, targetDay); } } return anniversary.getTime(); }
From source file:br.com.grupofortress.controller.Agendamentos.java
public void terceiraTarefa() { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 9); c.set(Calendar.MINUTE, 40); c.set(Calendar.SECOND, 0);/*from w w w . j a va 2 s .c om*/ Date time = c.getTime(); final Timer t = new Timer(); t.schedule(new TimerTask() { @Override public void run() { System.out.println( "Enviando email _________________________________________________________________ \n"); ClientesDao cli = new ClientesDao(); int qtdSemComunicacao = 0; String msg = "<table width=\"100%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" bgcolor=\"#CCCCCC\">\n" + " <tr>\n" + " <td bgcolor=\"#CC0000\"><font size=1 face=\"verdana, arial, helvetica\" color=\"#FFFFFF\"><b>Clientes Sem Comunicao</b></font></td>\n" + " </tr>\n" + " <tr>\n" + " <td bgcolor=\"#F5ECB9\"><table width=\"95%\" cellspacing=\"1\" cellpadding=\"1\" border=\"0\" align=\"center\">\n" + " <tr>\n" + " <td valign=top><font face=\"verdana, arial, helvetica\" size=1><strong>Cdigo</strong></font></td>\n" + " <td><font face=\"verdana, arial, helvetica\" size=1><strong>Nome</strong></font></td>\n" + " <td><font size=\"1\" face=\"verdana, arial, helvetica\"><strong>Ultimo Evento Recebido</strong></font></td>"; for (Cliente cliente : cli.getClientesSemComunicacao("")) { qtdSemComunicacao++; msg = msg + "<tr>" + " <td valign=top><font face=\"verdana, arial, helvetica\" size=1>" + cliente.getCli_codigo() + "</font></td>\n" + " <td><font face=\"verdana, arial, helvetica\" size=1>" + cliente.getCli_nome() + "</font></td>\n" + " <td><font size=\"1\" face=\"verdana, arial, helvetica\">" + Universal.getInstance().calendarToString(cliente.getCli_ultima_comunicacao()) + "</font></td>" + "</tr>"; } msg = msg + " </table></td>\n" + " </tr>\n" + " <tr>\n" + " <td bgcolor=\"#CCCCCC\"><font size=1 face=\"verdana, arial, helvetica\"><b>Total de Clientes sem Comunicao: " + qtdSemComunicacao + "</b></font></td>\n" + "</tr>" + "</table> "; CommonsMail enviaEmail = new CommonsMail(); try { enviaEmail.enviaEmailFormatoHtml(formatString(msg)); } catch (EmailException ex) { Logger.getLogger(GerarTarefasAgendadas.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(GerarTarefasAgendadas.class.getName()).log(Level.SEVERE, null, ex); } } }, time); }
From source file:net.seratch.taskun.util.CalendarUtil.java
public static Integer getMinute(Calendar calendar) { Integer minute = calendar.get(Calendar.MINUTE); return minute; }
From source file:Main.java
/** * * This method is a utility method to create a new java.sql.Date in one line. * * @param year// w ww . j a va 2s . c o m * @param month * @param day * * @return a populated java.sql.Date with the year, month, and day specified, and no values for hour, minute, second, * millisecond * */ public static java.sql.Date newDate(Integer year, Integer month, Integer day) { // test for null arguments if (year == null) { throw new IllegalArgumentException("Argument 'year' passed in was null."); } if (month == null) { throw new IllegalArgumentException("Argument 'month' passed in was null."); } if (day == null) { throw new IllegalArgumentException("Argument 'day' passed in was null."); } Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.clear(Calendar.HOUR_OF_DAY); calendar.clear(Calendar.MINUTE); calendar.clear(Calendar.SECOND); calendar.clear(Calendar.MILLISECOND); return new java.sql.Date(calendar.getTimeInMillis()); }
From source file:Main.java
public static Date getDateTimeFrom(Date time, Date date) { Date iTime, iDate;/*from ww w.ja v a 2 s. c om*/ Calendar calendar = Calendar.getInstance(); if (date == null) { iTime = time; iDate = new Date(); } else { iTime = time; iDate = date; } Calendar calendarDate = Calendar.getInstance(); calendarDate.setTime(iDate); Calendar calendarTime = Calendar.getInstance(); if (iTime != null) calendarTime.setTime(iTime); if (iTime != null) { calendar.set(Calendar.MINUTE, calendarTime.get(Calendar.MINUTE)); calendar.set(Calendar.HOUR_OF_DAY, calendarTime.get(Calendar.HOUR_OF_DAY)); } else { calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); } //calendar.set(Calendar.AM_PM, calendarTime.get(Calendar.AM_PM) ); calendar.set(Calendar.DAY_OF_MONTH, calendarDate.get(Calendar.DAY_OF_MONTH)); calendar.set(Calendar.MONTH, calendarDate.get(Calendar.MONTH)); calendar.set(Calendar.YEAR, calendarDate.get(Calendar.YEAR)); Date ret = calendar.getTime(); Log.v("!!!!!!!!!! calendar=", "" + ret); return ret; }
From source file:TimeUtil.java
public static short modFormat(long msecs) { synchronized (statFmtCal) { statFmtCal.setTime(new Date(msecs)); return ((short) (statFmtCal.get(Calendar.HOUR_OF_DAY) * 60 + statFmtCal.get(Calendar.MINUTE))); }//from w w w .j ava2 s .c om }
From source file:Main.java
/** * Copy the hour and minutes from a date to another * @param cOrigin Calendar origin where to get the data * @param cDestiny Calendar destiny where to set the data * @return Calendar with hour and minutes from dateOrigin and rest from dateDestiny *//*w w w . java 2s . co m*/ public static Calendar copyHourMinute(Calendar cOrigin, Calendar cDestiny) { //check null values if (cOrigin == null && cDestiny == null) { return Calendar.getInstance(); } else if (cOrigin == null) { return cDestiny; } else if (cDestiny == null) { return cOrigin; } //copy year, month and day cDestiny.set(Calendar.HOUR_OF_DAY, cOrigin.get(Calendar.HOUR_OF_DAY)); cDestiny.set(Calendar.MINUTE, cOrigin.get(Calendar.MINUTE)); //return the time of destiny return cDestiny; }
From source file:Main.java
public static File getEmptyFileWithStructuredPath(String course_title, String format) { Calendar calendar = Calendar.getInstance(); int date = calendar.get(Calendar.DATE); int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); StringBuffer dateInString = new StringBuffer(); dateInString.append(month);//from w w w . ja va2s . c om dateInString.append("-"); dateInString.append(date); dateInString.append("-"); dateInString.append(year); StringBuffer timeInString = new StringBuffer(); timeInString.append(hour); timeInString.append("_"); timeInString.append(minute); timeInString.append("_"); timeInString.append(second); Log.d("File Storage", "DateTime : " + dateInString + timeInString); String folderPathInString = Environment.getExternalStorageDirectory().toString() + "/" + LECTURE_HELPER + "/" + course_title + "/" + dateInString + "/"; File folderPath = new File(folderPathInString); if (!folderPath.exists()) { folderPath.mkdirs(); } return new File(folderPath.getPath() + "/" + FILE_NAME_TO_SAVE + timeInString + format); }