List of usage examples for java.util Calendar clear
public final void clear()
Calendar
undefined. From source file:org.wiztools.commons.DateUtil.java
@Test public void testGetDatePlusDays() { System.out.println("getDatePlusDays"); Calendar c = Calendar.getInstance(); c.clear(); c.set(Calendar.YEAR, 1979); c.set(Calendar.MONTH, 1); // 1 means Feb. c.set(Calendar.DATE, 15); Date date = DateUtil.getDatePlusDays(c.getTime(), 5); assertEquals(new SimpleDateFormat("dd-MM-yyyy").format(date), "20-02-1979"); }//w w w . j a v a 2 s .co m
From source file:org.wiztools.commons.DateUtil.java
/** * Test of getAsISODateTimeString method, of class DateUtil. *//*from ww w. java 2 s . co m*/ @Test public void testGetAsISODateTimeString() { System.out.println("getAsISODateTimeString"); Calendar c = Calendar.getInstance(); c.clear(); c.set(Calendar.YEAR, 1979); c.set(Calendar.MONTH, 1); // 1 means Feb. c.set(Calendar.DATE, 15); c.set(Calendar.HOUR, 5); c.set(Calendar.MINUTE, 5); c.set(Calendar.SECOND, 5); Date date = c.getTime(); String expResult = "1979-02-15T05:05:05"; String result = DateUtil.getAsISODateTimeString(date); assertEquals(expResult, result); }
From source file:org.shredzone.cilla.web.renderer.CalendarGenerator.java
/** * Sets the {@link SearchResult} to create a calendar for. * <p>/*from w ww . j a v a 2 s. c o m*/ * Must be invoked after {@link #setLocale(Locale)}. * * @param result * {@link SearchResult}, may be {@code null} for the current calendar */ public void setSearchResult(SearchResult result) throws CillaServiceException { filter = new FilterModel(); date = new DateRange(); pageDays = Collections.emptySet(); if (result != null) { filter = result.getFilter(); if (filter.getDate() != null) { date = filter.getDate(); } else { date = new DateRange(); } } setup(); if (result != null) { Calendar cal = Calendar.getInstance(locale); cal.clear(); cal.set(calYear, calMonth - 1, 1); pageDays = result.fetchPageDays(cal); } }
From source file:py.una.pol.karaku.replication.client.ReplicationLogic.java
private Calendar getNextSync(ReplicationInfo ri) { Calendar last = Calendar.getInstance(); Date lastReplicated = ri.getLastSync(); if (ri.getLastSync() == null) { last.clear(); // seteamos al principio de los tiempos, para que s o // s se sincronize } else {/*from w w w . java 2s . c o m*/ last.setTime(lastReplicated); last.add(Calendar.MINUTE, ri.getInterval()); } return last; }
From source file:com.clustercontrol.commons.util.JpaSessionEventListener.java
/** * PUBLIC://from w w w . j a v a 2s .com * This event is raised on when using the server/client sessions. * This event is raised before a connection is released into a connection pool. */ public void preReleaseConnection(SessionEvent event) { m_log.debug("Connection release to connection pool"); HinemosEntityManager em = null; em = (HinemosEntityManager) HinemosSessionContext.instance().getProperty(JpaTransactionManager.EM); if (em != null) { setMaxQueueSize(HinemosPropertyUtil .getHinemosPropertyNum("common.db.connectionpool.stats.threshold", Long.valueOf(12)) .intValue()); ServerSession ss = em.unwrap(ServerSession.class); // Hinemos 6.0???????????? // ???????????????????? for (ConnectionPool pool : ss.getConnectionPools().values()) { int used = (pool.getTotalNumberOfConnections() - pool.getConnectionsAvailable().size()); if (m_log.isDebugEnabled()) { m_log.debug("Pool name=" + pool.getName() + ", Used size=" + used + ", Free size=" + pool.getConnectionsAvailable().size()); m_log.debug("Initial=" + pool.getInitialNumberOfConnections() + ":Min=" + pool.getMinNumberOfConnections() + ":Max=" + pool.getMaxNumberOfConnections()); } // Min???? if (used > pool.getMinNumberOfConnections()) { if (m_log.isDebugEnabled()) m_log.info("update min setting:" + pool.getMinNumberOfConnections() + "->" + used + "/max(" + pool.getMaxNumberOfConnections() + ")"); pool.setMinNumberOfConnections(used); } // 1???????"X0"?????????????? // ?????????Min?(?????????) Calendar now = HinemosTime.getCalendarInstance(); Calendar comparetime = (Calendar) now.clone(); // ""???? comparetime.clear(); comparetime.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE), now.get(Calendar.HOUR_OF_DAY), 0, 0); // ???1???????????(???) // comparetime.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE), now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), 0); synchronized (queueUpdateLock) { // ??"X0"??????("X0"?????)??? if (lastAddTime < comparetime.getTimeInMillis()) { if (m_log.isDebugEnabled()) m_log.debug("add queue:used=" + used); queue.addLast(new DBConnectionPoolStats(now.getTimeInMillis(), used)); lastAddTime = now.getTimeInMillis(); // ???? while (queue.size() > maxQueueSize) { if (m_log.isDebugEnabled()) m_log.debug( "remove queue: currentSize=" + queue.size() + ", maxSize=" + maxQueueSize); queue.removeFirst(); } // Min(??)????? int max = used; for (DBConnectionPoolStats stats : queue) { if (stats.getMaxUseCount() > max) max = stats.getMaxUseCount(); } if (m_log.isDebugEnabled()) m_log.debug("max use:" + max); if (pool.getMinNumberOfConnections() > max) { if (m_log.isDebugEnabled()) m_log.info("update min setting(from stats):" + pool.getMinNumberOfConnections() + "->" + used + "/max(" + pool.getMaxNumberOfConnections() + ")"); pool.setMinNumberOfConnections(max); } } // ????????? else if (used > queue.peekLast().getMaxUseCount()) { if (m_log.isDebugEnabled()) m_log.debug("update queue:used=" + used); queue.peekLast().setMaxUseInfo(now.getTimeInMillis(), used); } } } } if (m_log.isTraceEnabled()) { StackTraceElement[] elements = Thread.currentThread().getStackTrace(); for (StackTraceElement element : elements) { m_log.trace("preReleaseConnection():" + element); } } }
From source file:org.richfaces.component.CalendarComponentTest.java
public void testCalendarTime() throws Exception { Calendar calendarObject = Calendar.getInstance(); calendarObject.clear(); calendarObject.set(2001, Calendar.SEPTEMBER, 11, 13, 36); assertEquals(calendarObject.getTime().toString(), calendar2.getValue().toString()); }
From source file:com.square.client.gwt.server.test.StringConverterTest.java
/** * Test de recuperation des criteres.//from w w w . ja v a 2 s . c o m */ @SuppressWarnings("unchecked") @Test public void testRecupererCriteres() { final SimpleDateFormat sdf = new SimpleDateFormat(Messages.getString("StringConverterTest.34")); final Map<String, String> map = new HashMap<String, String>(); map.put("adresse", "uneAdresse"); map.put("dateNaissance", sdf.format(Calendar.getInstance().getTime())); map.put("idAgences", "java.lang.Long:1;5;8"); map.put("rechercheStricte", "true"); map.put("listeSorts", Messages.getString("StringConverterTest.43")); resetConverter(); final RemotePagingCriteriasDto<PersonneCriteresRechercheDto> criteres = (RemotePagingCriteriasDto<PersonneCriteresRechercheDto>) recupererCriteres( map, new PersonneCriteresRechercheDto()); final Calendar date = Calendar.getInstance(); final Calendar dateCopie = Calendar.getInstance(); date.clear(); date.set(dateCopie.get(Calendar.YEAR), dateCopie.get(Calendar.MONTH), dateCopie.get(Calendar.DAY_OF_MONTH)); final List<Long> idsAgences = new ArrayList<Long>(); idsAgences.add(1L); idsAgences.add(5L); idsAgences.add(8L); final List<RemotePagingSort> listeSorts = new ArrayList<RemotePagingSort>(); listeSorts.add(new RemotePagingSort("nom", RemotePagingSort.REMOTE_PAGING_SORT_DESC)); listeSorts.add(new RemotePagingSort("dateFin", RemotePagingSort.REMOTE_PAGING_SORT_ASC)); assertEquals(Messages.getString("StringConverterTest.46"), Messages.getString("StringConverterTest.47"), criteres.getCriterias().getAdresse()); assertEquals(Messages.getString("StringConverterTest.48"), date, criteres.getCriterias().getDateNaissance()); assertEquals(Messages.getString("StringConverterTest.49"), true, criteres.getCriterias().isRechercheStricte()); assertEquals(Messages.getString("StringConverterTest.50"), idsAgences.toString(), criteres.getCriterias().getIdAgences().toString()); boolean existTriNom = false; boolean existTriDateFin = false; for (RemotePagingSort remotePagingSort : listeSorts) { if (remotePagingSort.getSortField().equals("nom")) { assertEquals(Messages.getString("StringConverterTest.52"), RemotePagingSort.REMOTE_PAGING_SORT_DESC, remotePagingSort.getSortAsc()); existTriNom = true; } else if (remotePagingSort.getSortField().equals("dateFin")) { assertEquals(Messages.getString("StringConverterTest.54"), RemotePagingSort.REMOTE_PAGING_SORT_ASC, remotePagingSort.getSortAsc()); existTriDateFin = true; } else { fail(Messages.getString("StringConverterTest.55") + remotePagingSort.getSortField()); } } assertTrue(Messages.getString("StringConverterTest.56"), existTriNom); assertTrue(Messages.getString("StringConverterTest.57"), existTriDateFin); }
From source file:org.photovault.imginfo.Test_PhotoQuery.java
@Test public void testBoundedRange() { PhotoQuery q = new PhotoQuery(); Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(2002, 11, 24);//from w ww .j a v a 2 s. co m // First the case in which there is only lower bound q.setFieldCriteriaRange(PhotoQuery.FIELD_SHOOTING_TIME, cal.getTime(), cal.getTime()); boolean[] expected2 = { false, true, true, false }; checkResults(q, expected2); }
From source file:org.photovault.imginfo.Test_PhotoQuery.java
@Test public void testUpperUnboundedRange() { PhotoQuery q = new PhotoQuery(); Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(2002, 11, 24);//from w ww .j a v a 2 s. c om // First the case in which there is only lower bound q.setFieldCriteriaRange(PhotoQuery.FIELD_SHOOTING_TIME, cal.getTime(), null); boolean[] expected1 = { false, true, true, true }; checkResults(q, expected1); }
From source file:org.photovault.imginfo.Test_PhotoQuery.java
@Test public void testLowerUnboundedRange() { PhotoQuery q = new PhotoQuery(); Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(2002, 11, 24);/*from w ww .j a v a 2 s.c o m*/ // First the case in which there is only lower bound q.setFieldCriteriaRange(PhotoQuery.FIELD_SHOOTING_TIME, null, cal.getTime()); boolean[] expected3 = { true, true, true, false }; checkResults(q, expected3); }