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.apextom.util.DateUtil.java
/** * ????.yyyy-MM-dd HH:mm/*w ww . ja v a2 s . c o m*/ * * @param date * @param formatFormat * @return */ public static Date getMinuteDate(String date, String formatFormat) { Calendar cal = Calendar.getInstance(); cal.setTime(strToDate(date, formatFormat)); cal.set(Calendar.SECOND, 0); return cal.getTime(); }
From source file:org.openmrs.module.uiframeworkpatientsummarysupport.fragment.controller.PatientObsFlowsheetFragmentController.java
/** * This method was actually added in core as of 1.9 */// w w w . j a v a2 s . c o m private static Date startOfDay(Date date) { if (date == null) return null; Calendar c = Calendar.getInstance(); c.setTime(date); 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:be.fedict.eid.pkira.common.util.FilterHelperBean.java
private Date changeTime(Date date, int hours, int minutes, int seconds) { Calendar calendar = new GregorianCalendar(); calendar.setTime(date);//from w ww . j a v a 2 s .c o m calendar.set(Calendar.HOUR, hours); calendar.set(Calendar.MINUTE, minutes); calendar.set(Calendar.SECOND, seconds); return calendar.getTime(); }
From source file:net.seratch.taskun.util.CalendarUtil.java
public static Calendar getCalendar(String yyyy, String mm, String dd, String hh, String mi, String ss) { Calendar cal = getCalendar(yyyy, mm, dd); cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(hh)); cal.set(Calendar.MINUTE, Integer.valueOf(mi)); cal.set(Calendar.SECOND, Integer.valueOf(ss)); return cal;/* ww w.j ava2 s .c o m*/ }
From source file:cognitivabrasil.obaa.Technical.Duration.java
/** * * @param value The value of the field//from w ww. j a v a 2 s . co m * @param field The Java Calendar constant that reprensents the field, need * to be Calendar.HOUR, Calendar.MINUTE or Calendar.SECOND */ public void set(int value, int field) { if (field == Calendar.HOUR) { hours = value; } if (field == Calendar.MINUTE) { minutes = value; } if (field == Calendar.SECOND) { seconds = value; } StringBuilder builder = new StringBuilder("PT"); if (hours != 0) { builder.append(hours); builder.append("H"); } if (minutes != 0) { builder.append(minutes); builder.append("M"); } if (seconds != 0) { builder.append(seconds); builder.append("S"); } super.setText(builder.toString()); }
From source file:com.adobe.acs.commons.http.headers.impl.WeeklyExpiresHeaderFilterTest.java
@Test public void testAdjustExpiresPastWeekday() throws Exception { Calendar actual = Calendar.getInstance(); actual.set(Calendar.SECOND, 0); actual.set(Calendar.MILLISECOND, 0); Calendar expected = Calendar.getInstance(); expected.setTime(actual.getTime());// w w w . java2 s . c o m expected.add(Calendar.DAY_OF_WEEK, -3); expected.add(Calendar.DAY_OF_WEEK, 7); int dayOfWeek = expected.get(Calendar.DAY_OF_WEEK); properties.put(WeeklyExpiresHeaderFilter.PROP_EXPIRES_DAY_OF_WEEK, dayOfWeek); filter.doActivate(componentContext); filter.adjustExpires(actual); assertTrue(DateUtils.isSameInstant(expected, actual)); assertEquals(dayOfWeek, actual.get(Calendar.DAY_OF_WEEK)); }
From source file:XSDDateTime.java
public static String getDateTime(Calendar cal) { if (!cal.getTimeZone().equals(TimeZone.getTimeZone("GMT+00:00"))) { throw new InvalidParameterException(); }/*from w ww.j a va 2s . co m*/ int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); month++; String monthString = pad(month); int day = cal.get(Calendar.DAY_OF_MONTH); String dayString = pad(day); int hour = cal.get(Calendar.HOUR_OF_DAY); String hourString = pad(hour); int minutes = cal.get(Calendar.MINUTE); String minutesString = pad(minutes); int seconds = cal.get(Calendar.SECOND); String secondsString = pad(seconds); return year + "-" + monthString + "-" + dayString + "T" + hourString + ":" + minutesString + ":" + secondsString + "Z"; }
From source file:org.jasig.cas.web.support.InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapter.java
@Override protected final int findCount(final HttpServletRequest request, final String usernameParameter, final int failureRangeInSeconds) { final String SQL = "Select count(*) from COM_AUDIT_TRAIL where AUD_CLIENT_IP = ? and AUD_USER = ? AND AUD_ACTION = ? AND APPLIC_CD = ? AND AUD_DATE >= ?"; final String userToUse = constructUsername(request, usernameParameter); final Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.SECOND, -1 * failureRangeInSeconds); final Date oldestDate = calendar.getTime(); return this.jdbcTemplate.queryForInt(SQL, new Object[] { request.getRemoteAddr(), userToUse, INSPEKTR_ACTION, this.applicationCode, oldestDate },/*from w w w. ja va 2s . c o m*/ new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP }); }
From source file:org.atomspace.ultrahouse3000.translator.Message2DocumentTranslator.java
void addCalenderInformation(Message message) { Calendar cal = Calendar.getInstance(); message.setHeader("timestamp", cal.getTimeInMillis()); message.setHeader("calendarYear", cal.get(Calendar.YEAR)); message.setHeader("calendarDayOfMonth", cal.get(Calendar.DAY_OF_MONTH)); message.setHeader("calendarMonth", cal.get(Calendar.MONTH)); message.setHeader("calendarDayOfYear", cal.get(Calendar.DAY_OF_YEAR)); message.setHeader("calendarHourOfDay", cal.get(Calendar.HOUR_OF_DAY)); message.setHeader("calendarMinute", cal.get(Calendar.MINUTE)); message.setHeader("calendarSecond", cal.get(Calendar.SECOND)); message.setHeader("calendarWeekOfYear", cal.get(Calendar.WEEK_OF_YEAR)); message.setHeader("calendarDayOfWeek", cal.get(Calendar.DAY_OF_WEEK)); }
From source file:com.adobe.acs.commons.http.headers.impl.MonthlyExpiresHeaderFilterTest.java
@Test public void testAdjustExpiresPastDay() throws Exception { Calendar actual = Calendar.getInstance(); actual.set(Calendar.SECOND, 0); actual.set(Calendar.MILLISECOND, 0); Calendar expected = Calendar.getInstance(); expected.setTime(actual.getTime());/*from w w w . j a v a 2 s . c o m*/ expected.add(Calendar.DAY_OF_MONTH, -3); expected.add(Calendar.MONTH, 1); actual.set(Calendar.DAY_OF_MONTH, 15); final int month = expected.get(Calendar.MONTH); properties.put(MonthlyExpiresHeaderFilter.PROP_EXPIRES_DAY_OF_MONTH, expected.get(Calendar.DAY_OF_MONTH)); filter.doActivate(componentContext); filter.adjustExpires(actual); assertTrue(DateUtils.isSameInstant(expected, actual)); assertEquals(month, actual.get(Calendar.MONTH)); }