List of usage examples for java.util Calendar SECOND
int SECOND
To view the source code for java.util Calendar SECOND.
Click Source Link
get
and set
indicating the second within the minute. From source file:com.ekom.ekomerp.global.DateTimeUtils.java
public static Calendar getCalendarWithoutTime(Date date, Locale locale) { Calendar calendar = Calendar.getInstance(locale); calendar.setTime(date);// w w w . j a v a 2s . co m calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; }
From source file:com.wiiyaya.framework.common.utils.DateUtils.java
/** * ?23:59:59/*from ww w. j a va2s . c o m*/ * @param date * @return ?? */ public static Date setDayEnd(final Date date) { final Calendar c = Calendar.getInstance(); c.setLenient(false); c.setTime(date); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); return c.getTime(); }
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);// ww w . j a v a 2 s. co m 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 w w.jav a2 s . co 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./*www . j a v a 2 s .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);/*from w w w .jav a2 s .c om*/ c.set(Calendar.SECOND, 0); 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:Main.java
/** * * This method is a utility method to create a new java.sql.Date in one line. * * @param year//ww w .j a v a 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:net.seratch.taskun.util.CalendarUtil.java
public static Integer getSecond(Calendar calendar) { Integer second = calendar.get(Calendar.SECOND); return second; }
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 . j av a2s. c o m 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); }
From source file:cz.cvut.kbss.wpa.service.test.PlayerServiceTest.java
@BeforeClass public static void setUp() { b = Calendar.getInstance();/*from www. j a v a 2 s .c o m*/ b.set(Calendar.YEAR, 1986); b.set(Calendar.MONTH, Calendar.APRIL); b.set(Calendar.DAY_OF_MONTH, 28); b.set(Calendar.HOUR, 0); b.set(Calendar.MINUTE, 0); b.set(Calendar.SECOND, 0); }